# PHPStorm and Trellis

**URL:** https://discourse.roots.io/t/phpstorm-and-trellis/9962
**Category:** trellis
**Created:** 2017-07-10T18:25:19Z
**Posts:** 8

## Post 1 by @zigav — 2017-07-10T18:25:20Z

Hello,

I am wondering if anyone has a practical project configuration with PhpStorm and Trellis. I’ve been trying to configure it for a few days now but with no success. The main thing I am trying to do is get xdebug working.

My process so far:

1. Create a new project from existing files (Web server is installed locally, source files are located under its document root)
2. As project root I pick the current roots theme I am developing /site\_name/site/web/app/themes/site\_nametheme
3. Specify local server (use existing server configured for the site http://site\_name.dev)
4. Web path for project root is ‘/’
5. Include wp-admin, wp-includes, and other plugins I want as external PHP libraries
6. Connect the Vagrant instance folder and executable from Tools-\>Vagrant
7. Set PHP Language Level (7.1) and CLI interpreter (Remote PHP 7.1 from Vagrant)

What am I missing?

---

## Post 2 by @patrickv — 2017-07-10T18:31:11Z

> [@Setting up PhpStorm + Xdebug with Trellis [walkthrough]](https://discourse.roots.io/t/setting-up-phpstorm-xdebug-with-trellis-walkthrough/7506):
>
> I had been having a hard time getting Xdebug going in Trellis with PhpStorm’s debugger. It was easy to get setup in VVV but I could never get the path mappings right in Trellis. Turns out it’s super easy with PhpStorm’s Zero-Configuration Debugging. I did a quick screen cast if anyone is interested: …but the short of it is: Install one of the [JetBrains bookmarklets](https://www.jetbrains.com/phpstorm/marklets/), or use a browser extension like [this one for Firefox,](https://addons.mozilla.org/en-US/firefox/addon/the-easiest-xdebug/) or [this one for Chrome](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en), or whatever. Give your extension the IDE key XD…

---

## Post 3 by @zigav — 2017-07-10T18:34:07Z

I saw and tried that, but I still have no idea how he configured his project. In short, it did not work for me. Thank you anyway.

---

## Post 4 by @smutek — 2017-07-10T19:02:49Z

Hey, I’m at work but I’ll take a look this evening and see if maybe I can help you troubleshoot.

Off the top of my head - check to make sure the IDE key is entered correctly.

Also, be sure to place a breakpoint somewhere that is going to be picked up by the compiler. Like, if a breakpoint is set inside a conditional, like ‘if($foo):’, make sure $foo is true, otherwise your breakpoint gets skipped.

Last I checked, if using Sage 9, the debugger will not pick up breakpoints in blade files. So there’s that.

---

## Post 5 by @zigav — 2017-07-11T10:21:53Z

Thank you, the problem is that I don’t even get the connection from XDEBUG helper to PhpStorm when I start ‘listening’.

---

## Post 6 by @patrickv — 2017-07-11T13:43:30Z

Have you tried changing theTrellis xdebug port to something other than default (9000)? You would do that in `group_vars/development/php.ini` and reprovision. You also need to change PHPStorm config to listen to the new port number.

```
xdebug_remote_enable: 1
xdebug_remote_connect_back: 1
xdebug_remote_port: 10000
```

---

## Post 7 by @kalenjohnson — 2017-07-11T16:00:37Z

Sometimes in development I also use `xdebug_remote_autostart: 1`, so I don’t need to remember to turn it on via the browser.

---

## Post 8 by @smutek — 2017-07-12T02:07:14Z

Try this -

> Create a new project from existing files (Web server is installed locally, source files are located under its document root)

This is good.

> As project root I pick the current roots theme I am developing /site\_name/site/web/app/themes/site\_nametheme

I believe _most_ of your problem is here. Don’t set your theme as the root, set the topmost directory as root. PHP Storm needs to be able to map the local path to its corresponding path on the VM, so while I’m sure it’s possible to set the theme as the root, I’ve always set the server root as my project root.

So, in your example, the root should be `/site_name/` Make sure it’s the full path as well. (Just use the little dots to open a dialog and navigate to your project root).

 ![](https://discourse.roots.io/uploads/default/original/2X/4/4482ce9907c51708a93d5bed5d7b7967a881475f.png)

 ![](https://discourse.roots.io/uploads/default/original/2X/8/89b53701656e98456f5b0fad768fc55030b5de22.png)

I just set up a test project to make sure, everything is working fine. Here’s my directory settings, and my project tree drawer thing.

 ![](https://discourse.roots.io/uploads/default/original/2X/5/511902af81a4444fcee74466ec9cc95219742aa6.png)

![](https://discourse.roots.io/uploads/default/original/2X/1/141aa71ef84782acf0e39836b87ac6a5fbb28dcb.png)

> Specify local server (use existing server configured for the site http://site\_name.dev)  
> Web path for project root is ‘/’

You don’t have to do any of this stuff anymore. Use PHP Storm’s “zero config debug”. First, go in to preferences/languages & frameworks/php/servers and delete any servers you’ve manually set up. I don’t know if debug configurations are still being used, but if you have any of those set up, delete them as well.

 ![](https://discourse.roots.io/uploads/default/original/2X/3/363debd1b6bae2ad3f80f1267c5026e60edda487.png)

Install one of the Xdebug helper plugins, they are both linked in my post but [here’s the Chrome plugin](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en).

In the xDebug browser extension, set the IDE key to `PHPSTORM`…

![](https://discourse.roots.io/uploads/default/original/2X/2/288bfbbc37b6e9893311a0eba2b4712aba94a89f.png)

 ![](https://discourse.roots.io/uploads/default/original/2X/7/7f1ce4dea231429e346b4416f7f016804d3bb2ec.png) 

…then come back out to your browser and enable the extension.

![](https://discourse.roots.io/uploads/default/original/2X/b/bd5036d2bd519c02afcde7362f4145a09ae35e46.png)

Set a breakpoint in your code somewhere and click the little phone to tell PHP Storm to listen for incoming connections. I set one on the required files function in `resources/functions.php` because I’m testing, and I know that function runs on every page load. Also, I haven’t been able to get the debugger to work in blade files. I haven’t tried recently, so maybe that has changed.

 ![](https://discourse.roots.io/uploads/default/original/2X/0/0fb7f7924646cfa496b240cc78ae673c012b65fb.png)

Anyway, switch back to your browser, refresh the page, and if you did everything correctly you should immediately see this dialog -

 ![](https://discourse.roots.io/uploads/default/original/2X/d/d659ca661b9593043fe8c1172f5cdc012ffec212.png)

Just click accept and you’ll be de-buggin’.

![](https://discourse.roots.io/uploads/default/original/2X/a/a047f36b9030cc8585e9a0b944b9f7eb00a97081.png)

Hope this was helpful.
