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

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"
  3. 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!


3 thoughts on “Quick Tip: Debug PHP Scripts from the Command Line using PHPStorm 6”

What are your 10 bits on the matter? I want to know!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s