You can paste that setting in (I use Path Finder, which has a "Copy UNIX Path" command that makes this easy), or use the ellipsis button to open a standard file dialog from which you navigate to it.įinally, you should add the command line options that will tell Xdebug to make itself available in a way that PhpStorm can see. Applications/MAMP/bin/php/php7.0.8/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so For MAMP, that path will look something like this depending on the version of PHP:
To make Xdebug available to each one, you can set its path in the "Debugger extension" setting. I've added each of the PHP binaries for versions 5.3 through 7 that come with MAMP. To get to this quickly, use Help > Find Action (on macOS use Cmd-Shift-A) and type "CLI Interpreter" (you won't have to type all of it). There is a project setting for CLI Interpreter with a little ellipsis button.Ĭlick that to open a CLI Interpreter settings, where you can tell PhpStorm where to find any versions of PHP you can access to, both locally and remotely. Go to Preferences > Languages & Frameworks > PHP. I imagine there's a way to do this with environment variables or command line switches, but I wasn't able to find one that worked for me. This is actually a good thing, because Xdebug slows down PHP a lot, but you still need it when you want to debug. It includes Xdebug with all its PHP versions, which can be turned on in the PHP tab of its settings:īut if you run a command-line script like Drush or Artisan from the command line, even if you run them through the MAMP php binaries (see below), Xdebug will not be loaded automatically. I'm currently using MAMP Pro, about which I feel less cool all the time, but it continues to serve me well and not cause problems for the size of projects I'm usually working on. If all goes well, execution will stop at the breakpoint and you'll be off to the debugging races. Here's how this will work: you'll do some initial configuration in PhpStorm and your local web stack, set a breakpoint somewhere in your code, then run your command line script from within PhpStorm. Incidentally, if you've never tried a real debugger in your projects, you can check out my talk from WordCamp Orange County, "Let's Debug for Real", which was recorded from the audience, or a higher-fidelity version from a JavaScript perspective, my course Debugging the Web: JavaScript. Here's how I am currently working with all of these tools together. You can also set additional breakpoints, change the value by double clicking on a variable and go step by step through the request.Working for years with Drupal's command-line tool drush, and more recently with Laravel's artisan, I've had occasion to interface with Xdebug in my favorite IDE, PhpStorm. You can now view all the defined variables in your scope with the global variables like $_SERVER, $_COOKIE, $_GET and more.
In this case it is the index.php in the api directory.
Here we have to select the file in which the request starts. If you now reload the website you should get a new dialog in your PhpStorm window. Now open the local website you want to debug and enable the debugging mode in the right corner of the address bar by clicking on debug in the dropdown. There should appear a red circle at the line which you clicked. You can do this by clicking on the right of the line number.
PHPSTORM DEBUGGING CODE
Now add a breakpoint in your code which you want to debug. This will stop at every request even if you don’t set a breakpoint. It’s also a good idea to activate “Break at first line of PHP scripts”. We can now open our PhpStorm project and enable the debugging mode in “Run”, “Start Listening for PHP Debug Connections”. For this we can use Xdebug helper from the Chrome Web Store. Now we need a browser extension to enable the debug mode. Zend_extension = "C:\xampp\php\ext\php_xdebug.dll" We now need to replace this section with the following code: xdebug.profiler_output_name = "cachegrind.out.%t-%s" xdebug.profiler_output_dir = "C:\xampp\tmp" zend_extension = "C:\xampp\php\ext\php_xdebug.dll" For this we need to open our php.ini file (C:\xampp\php\php.ini)Īt the bottom of the file you should see the following commented section for the configuration of Xdebug. First let’s configure the our Php installation. Now that we’ve installed the Xdebug extension we need to configure it to work with our Php and Phpstorm installation. If you’re using a newer XAMPP version you should already have this file installed under C:\xampp\php\ext\php_xdebug.dll. You have to choose the right version for your installed php version.
PHPSTORM DEBUGGING DOWNLOAD
To start we need to download the latest Xdebug version from. With xdebug you can set breakpoints in your code, see all defined variable and even change them while running the code.