1
votes

I am trying to configure PhpStorm 2016.2 with Xdebug and Vagrant (Drupal VM). I have read many tutorials advising how to configure these three applications. I think it's almost there, but I'm not sure what this error is?

enter image description here

When I click to setup path mappings, it appears that 'File path in project' is the issue. On Vagrant I have:

  • /var/www/drupalvm/sitelog/index.php

On my local I have:

  • /Users/24ma13wg/PhpstormProjects/sitelog/index.php

...but I don't have index.php in my project files:

enter image description here

How can I resolve this? Thanks.


Aenter image description here

Benter image description here

1
1) "...but I don't have index.php in my project files:" That's because you have created a project only for part of your site. 2) "On my local I have: /Users/24ma13wg/PhpstormProjects/sitelog/index.php" -- you do not have that -- compare your paths again -- your screenshot shows that you have created project in subfolder (/sitelog/modules/sitelog) .. while index.php should be in /sitelog/index.php -- right now it's outside of the project. - LazyOne
True, index.php is outside of the project. I admit this is an unusual setup. I created my project from a git repo on drupal.org which only contains the module files. I added the rest of the site files around it, just to get a working site. Are you saying to get the debugger to work, all the site's files must be in the project - so I need to recreate my project. Apologies, I'm ignorant of how all these applications work. - dbj44
Well ... the way how you have created your project might be enough to do actual coding. But it's may not be good enough for debugging the whole site -- sorry, not a Drupal user myself so do not know the best practices etc. If tutorials that you have read/watched say that it can be debugged this way (only your module code) then ... look deeper. Right now IDE is looking for index.php as it's your site's entry point .. and it is not found in the project .. so from IDE side it's an indication of possible misconfiguration (it's a debug session, the file gets executed .. but you do not have it). - LazyOne
IDE has options at Settings/Preferences | Languages & Frameworks | PHP | Debug, In particular -- Force break at first line when a script is outside of the project -- it is what must be happening here. If you disable it .. the debugger should ignore this moment (that the script that is being executed is outside of the project) and should keep running as usual until breakpoint gets hit (when execution gets through Drupal's internals and reaches the point where it hits your actual files). In theory it should work (again: not a Drupal user myself so cannot state this for sure). - LazyOne
Some links just in case: 1) confluence.jetbrains.com/display/PhpStorm/… 2) confluence.jetbrains.com/display/PhpStorm/…. So ... 1) setup path mappings for the code that you have in your project (for your current project root it should be /var/www/drupalvm/sitelog/modules/sitelog) 2) disable that aforementioned option 3) review that 2nd link I gave you 4) try debugging again - LazyOne

1 Answers

2
votes

To solve the issue of needing to enable Force break at the first line when a script is outside the project can be solved by configuring PHPStorm to talk to the PHP Interpreter that is in DrupalVM.

Navigate to Preferences -> Languages and Frameworks -> PHP and click the ... next to CLI Interpreter. On the next window that pops up, click the + at the top and choose From Docker, Vagrant, VM, Remote. Choose the Vagrant Instance Folder by navigating to your local path to DrupalVM. Click OK on each of the open windows to close the options.

From here, you will just enable PHPStorm to start listening for new debug connections and will need to send a cookie along to allow to connect to xDebug.