Sure, dumping variables out is useful, but once you start getting into the habit of adding breakpoints in and viewing variable contents with Xdebug you’ll never look back! Now you should be ready to start debugging your PHP applications in a completely different way. To give it a go, open up a file (I’m using app/bootstrap/app.php) and add a breakpoint, then refresh your page. Once this setting has been added and saved, you should be able to add breakpoints in and debug your application.
In this case, my project was located within the default Code directory on Homestead which resides in /home/vagrant/ so the file mapping was /home/vagrant/Code/ which should be the general configuration for most Homestead users:
You’ll see that the ‘Absolute path on the server’ is missing, this needs to be filled in with the full location of the corresponding path on Homestead. You should now see a list of directories, the important one here is under ‘Project files’: To fix this error, click on the PHP|Servers link on the error message, or go to Preferences PHP Servers and select the server which you defined earlier. You’ll probably see this error when you refresh the page after setting up the incoming Xdebug connection: Then that should be it! Nope!įor some reason, PhpStorm has a bit of difficulty matching local paths with the remote ones on Homestead. In the above example, index.php is located in in public so I’d select the matching local version from the list of possible matches file and click accept. You need to configure PhpStorm so that it can match up the index.php file on Homestead with the local version on your development machine. A dialog box should open up in PhpStorm which looks like this: Now you need to accept an incoming connection from Xdebug in PhpStorm, so enable a debug session in your web browser (if you’re using Xdebug helper, click it’s icon and select ‘Debug’) and refresh your page. After you’ve installed it, make sure you go to it’s options and select PhpStorm under the IDE key section: If you choose to use Xdebug helper then you’ll need to configure it with PhpStorm’s IDE key. Essentially it does the same thing as the PhpStorm marklets, but I find it a whole lot neater! Xdebug helper adds a small icon to Chrome allowing us to enable and disable debug sessions, profile and trace sessions remotely. The method I now use is a Chrome extension called Xdebug helper. This is quite a simple approach which I used for a while, but in the end, I didn’t like having a bunch of buttons cluttering up my browser toolbar. If you visit PhpStorm’s Website then there’s a form you can use which generates a set of bookmarks which you can drag to your browsers’s bookmark toolbar. There’a few ways of doing this, I’ll cover the PhpStorm marklets and browser extensions which are both methods I’ve used myself. You’ll need to setup remote debugging from your web browser.
Setting Up A Debug Session In Your Browser Then you can click OK (the PHP interpreter path is the default /usr/bin/php at the time of writing - if this changes in future, it can be obtained by running php -i on Homestead and looking for $_SERVER): Now another window will open, you need to select the ‘Vagrant’ option and paste in the Vagrant path which you obtained from the console earlier on. On the next window, you need to click on the ‘+’ symbol in the top left corner to add the new interpreter, you should then select ‘Remote’ from the drop-down which appears: Now you need to open PhpStorm and open Preferences and then navigate to Languages & Frameworks PHP and select a new interpreter for our project by clicking the ellipsis next to the current setting: It’s quite easy to find since it’s stored in a directory named Homestead. You’ll notice that I have a few Vagrant boxes setup on my machine - we’re looking for Homestead though. With Vagrant commands from any directory. That directory and run Vagrant, or you can use the ID directly To interact with any of the machines, you can go to This data is cached and may not be completely The above shows information about all known Vagrant environments 4ff2702 default virtualbox poweroff /Users/ecs/websiteġa2b3c4 default virtualbox poweroff /Users/ecs/api-docsį812a16 default virtualbox running /Users/ecs/Homestead