Created
April 28, 2016 18:35
-
-
Save wdmtech/cb3b354e486f645face0a0e88213a3dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Full thanks to Lewis on laracasts for this! | |
https://laracasts.com/forum/?p=1648-phpstorm-homestead-xdebug/0 | |
--- | |
PHPStorm debugging is amazing | |
I recently installed Homestead for my development environment and discovered Xdebug needed some additional settings before it would work. Here's a step-by-step process that I used to get PHPStorm + Homestead + Xdebug working in harmony. | |
I'm going to assume you have installed PHPStorm and Homestead. | |
Configure Xdebug | |
Navigate to Tools>Vagrat>Up | |
Navigate to Tools>Start SSH Session and choose your vagrant host (PHPStorm automatically adds this) | |
In the terminal, sudo nano /etc/php5/fpm/conf.d/20-xdebug.ini | |
Paste the following into the file: | |
zend_extension=xdebug.so | |
xdebug.remote_enable = 1 | |
xdebug.remote_connect_back = 1 | |
xdebug.remote_port = 9000 | |
xdebug.scream=0 | |
xdebug.cli_color=1 | |
xdebug.show_local_vars=1 | |
To close and save the file, on Windows I do: Ctrl+x followed by y for yes and enter. | |
In the terminal, sudo service php5-fpm restart | |
Configure PHPStorm | |
Install the Chrome Xdebug helper extension. | |
Under the Xdebug helper's options, choose PHPStorm for the IDE key. | |
Set the extension to debug by clicking its icon in the Chrome address bar. | |
Open PHPStorm and set a breakpoint in your routes file for the route that you are currently viewing in Chrome. You can set a breakpoint (red dot) by clicking in the column just to the right of line numbers. | |
-image- | |
Navigate to Run>Start Listening for PHP Debug Connections. | |
Refresh in Chrome to initiate the debugging. | |
The debugging window should pop up in PHPStorm automatically. | |
The first time you debug, PHPStorm will alert you with the dialogue Incoming Connection from Xdebug. | |
Choose the root folder of your project and accept. | |
Lastly, the debug window will indicate there is an error with the path mappings. Click to set up the path mappings which should reflect what you have in your homestead.yaml file for folders. On my computer, my project root is H:\Accescape but I need to let PHPStorm know where the root is on the server which are set to /home/vagrant/Accescape. | |
-image- | |
Now, whenever you want to debug something all you have to do is start listening in PHPStorm and ensure that the Xdebug helper extension in chrome is set to Debug. | |
I learned the different debugging actions by just playing around with the debugger and watching this PHPStorm Webinar . It didn't take long for me to understand what stepping in and stepping out of functions did etc. | |
Hope this helps people! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment