Roots Discourse

PHPStorm and Trellis

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?

1 Like

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.

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.

1 Like

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

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

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

1 Like

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).

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.

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.

Install one of the Xdebug helper plugins, they are both linked in my post but here’s the Chrome plugin.

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


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

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.

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

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

Hope this was helpful.

7 Likes