Quick Tip: Debug PHP Scripts from the Command Line using PHPStorm 6

Published Sep 9, 2013 (11 years ago)
Danger icon
The last modifications of this post were around 11 years ago, some information may be outdated!

Quick Tip

I'm a big fan of PHPStorm. It has made my PHP development life so much easier, especially with debugging. I've been trying to debug a PHP script from the command line (to diagnose a cron job that runs on our server) and here's how you can do it using PHP Storm.

Note: This tip assumes that you already have PHP Storm running and debugging is successfully working. If you don't, check out this article on how you can get things setup.

  1. The first thing to do is to start up your site to debug as usual. Click the icon or hit Ctrl+D (or ^D for Mac users) to launch.

  2. The next step is to grab the "idekey" used by PHPStorm when it launched the debugger and add this to your CLI path environment. To do this, simply execute the following:

export XDEBUG_CONFIG="idekey=session_name"

  1. Finally, execute your PHP statement from the command prompt in your project directory. You should hit the proper breakpoints if you have them set.

That's it! I can't believe it took me this long to piece it together!