Question

How do I integrate Xdebug 2.2.3 (PHP 5.53) with the new PhpStorm 7.0?

The official documentation doesn't provide a step-by-step process.

Was it helpful?

Solution

My default setups

  1. MAMP 2.2. Installation directory is "default".
  2. Phpstorm 7.0. The basic config are done as per guided by the online doc.
  3. A Phpstorm project has been setup with sample codes ready for debugging.
  4. Chrome browser is used. Feel free to contribute if you would like to share on other browsers.

Configuring php.ini in MAMP to enable Xdebug

  1. Open /Applications/MAMP/bin/php/php5.4.4/conf/php.ini.
  2. Do remember to open the correct directory corresponding to the php ver of your choice. So if you want to use other versions, then note the corresponding version s/n such as /Applications/MAMP/bin/php/php(corresponding version number)/conf/php.ini.
  3. Go to last line and delete ";" before "zend_extension" to uncomment the line.
  4. Next, add this line below "xdebug.remote_enable = 1".
  5. The result should look like this:

    [xdebug]
    zend_extension="/Applications/MAMP/bin/php/php(**corresponding version number**)/lib/php/extensions/no-debug-non-zts-(**some numbers given.  Do not change**)/xdebug.so"
    xdebug.remote_enable = 1
    

Check if Xdebug is successfully enabled

  1. Restart your MAMP server.
  2. From Chrome, run "localhost:8888/MAMP/phpinfo.php".
  3. You should be able to find somewhere down the line for the Xdebug header. The first table row should show xdebug support > enabled.
  4. Note that xdebug.remote_enable table row should show "on".
  5. Note the port number of xdebug.remote_port. It should be "9000" by default..
  6. Note the IDE Key. Eventually, it should show "PHPSTORM" when you have successfully config Xdebug.
  7. To avoid complicating the config process, we are using all default values and directories. Once you've successfully configured and test driven the debugging feature, I reckon that it'll be easier to tune and customise your config.

Configuring PhpStorm 7.0

  1. Open PhpStorm.
  2. Goto Menubar > PhpStorm > Preferences > Project Settings > PHP.
  3. Reconfirm that you have config the "PHP language level" and "Interpreter" to your required PHP version.
  4. Click on "..." to open up a popup window.
  5. Under "PHP home", once again click on another "..." to open another window.
  6. Choose the correct PHP version via the Finder .
  7. For the default installation folder, it's at applications > MAMP > bin >php > php5.5.3(choose your version) > bin > click ok.
  8. Back at the previous popup window, you should see PhpStorm being able to detect the PHP version and the corresponding Xdebug ver. In my case it is PHP version 5.5.3 and Xdebug 2.2.3.
  9. Next, goto Menubar > Run > Edit Configutions > click "+" at top left-hand corner > PHP Web Application.
  10. Next, goto Menubar > PhpStorm > Preferences > Project Settings > PHP > Debug > DBGp Proxy.
  11. The "IDE Key" should show "PHPSTORM" as default.
  12. The "port" should show "9000" as default.1. Add Name.
  13. Choose current server from drop down menu or:
  14. Click on "...".
    • "Host" = localhost.
    • "Port" = 8888.
    • "Debugger" = Xdebug.
    • "Browser" = Chrome or any you would like (need to use corresponding browser debugging extension).

Installing Chrome's Xdebug Helper

  1. From Chrome, find Xdebug Helper and download + install it.
  2. You should see a grey bug icon at Chrome's address bar, right side.
  3. Right click on Bug icon > options > IDE Key > Dropdown menu > choose "PhpStorm" > close browser tab.
  4. Left Click on Bug icon > Debug.

Ready for Testdrive

  1. Now, from your PhpStorm's opened project, click on the "listen" icon. It's the icon with telephone icon + and "stop icon" + "Bug icon" all in one button. It's two buttons to the right of the debug button. The "stop icon" should disappear and replaced by a signals icon.
  2. Next, choose a few break points on your sample code
  3. Now, when you click on the debug button, Chrome should automatically open a new tab with your sample code/app running and suspended at your break point or point where you've configured to suspend at runtime by default.

Additional config: Administering Database right from PhpStorm

It's time to pop the champagne unless you want to do further setup to manage your database from within PhpStorm, which is another reason why IDE is great. You can refer to PhpStorm's very own online doc here.

Just to elaborate further on few of the procedures as mentioned in the doc that I thought might be helpful, here it goes:1. In PhpStorm, if you can't find the vertical "database" button at the right-hand-side, then simply click on a small button at the bottom-left-most corner. The button looks like a monitor icon. Doing that will toggle the vertical "database" button visible.

  1. Click on the vertical button of "database".
  2. Press COMD + N.
  3. From the dropdown menu, select new datasource.
  4. Under the first tab "Database" > JDBC driver files > select MySQL Connector/(some ver) > "Click here to download".
  5. At "Database URL", note that your url comprises:

    jdbc:mysql://localhost:8889/hello_database 
    where
    "hello_database" is the name of your database.
    8889 is the port number to your MySQL server.  Once again, 8889 is the default
    
  6. Config your database access credentials.

  7. If you don't have any existing db, then goto PhpMyAdmin to manually setup a new db and create new users with access credentials.
  8. Now back in PhpStorm, simply key in the same access credentials.
  9. Once your configurations are done correctly, you should see the database window populated by a list of your db tables.
  10. You can now manage your db directly from PhpStorm without having to do it separately from PhpMyAdmin.

Summary

The above steps are pretty lengthy, and this is the reason why I thought it might be helpful to some of you who might encounter some difficulties in the configurations. On the same note, if I have missed out any important steps, please feel free to add your comments. Hope this helps.

Update: Php5.53 seems to have a bug that does not allow Chrome to page-reload properly. For example, when I changed

from <?php echo 'Hello'?>
to <?php echo 'Hello Dale'?>

the word "Dale" does not refresh and appear on Chrome. My cache is disabled for dev just like any others would and I even tried Cache Killer for good measure. Finally, when I rolled back to php5.4.19 with it's corresponding Xdebug config, the refresh issue was no longer present. Let me know if you have a work around. Meanwhile, I'll have to make do with Php5.4.19.

OTHER TIPS

PHPStorm 8.0 (availabe thru EAP) fully integrates remote debugging (over SSH), including Vagrant boxes.

http://blog.jetbrains.com/phpstorm/2014/04/php-remote-interpreters-support-in-phpstorm-8-eap/#more-7367

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top