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.
My default setups
- MAMP 2.2. Installation directory is "default".
- Phpstorm 7.0. The basic config are done as per guided by the online doc.
- A Phpstorm project has been setup with sample codes ready for debugging.
- 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
- Open /Applications/MAMP/bin/php/php5.4.4/conf/php.ini.
- 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.
- Go to last line and delete ";" before "zend_extension" to uncomment the line.
- Next, add this line below "xdebug.remote_enable = 1".
-
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
- Restart your MAMP server.
- From Chrome, run "localhost:8888/MAMP/phpinfo.php".
- You should be able to find somewhere down the line for the Xdebug header. The first table row should show xdebug support > enabled.
- Note that xdebug.remote_enable table row should show "on".
- Note the port number of xdebug.remote_port. It should be "9000" by default..
- Note the IDE Key. Eventually, it should show "PHPSTORM" when you have successfully config Xdebug.
- 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
- Open PhpStorm.
- Goto Menubar > PhpStorm > Preferences > Project Settings > PHP.
- Reconfirm that you have config the "PHP language level" and "Interpreter" to your required PHP version.
- Click on "..." to open up a popup window.
- Under "PHP home", once again click on another "..." to open another window.
- Choose the correct PHP version via the Finder .
- For the default installation folder, it's at applications > MAMP > bin >php > php5.5.3(choose your version) > bin > click ok.
- 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.
- Next, goto Menubar > Run > Edit Configutions > click "+" at top left-hand corner > PHP Web Application.
- Next, goto Menubar > PhpStorm > Preferences > Project Settings > PHP > Debug > DBGp Proxy.
- The "IDE Key" should show "PHPSTORM" as default.
- The "port" should show "9000" as default.1. Add Name.
- Choose current server from drop down menu or:
- 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
- From Chrome, find Xdebug Helper and download + install it.
- You should see a grey bug icon at Chrome's address bar, right side.
- Right click on Bug icon > options > IDE Key > Dropdown menu > choose "PhpStorm" > close browser tab.
- Left Click on Bug icon > Debug.
Ready for Testdrive
- 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.
- Next, choose a few break points on your sample code
- 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.
- Click on the vertical button of "database".
- Press COMD + N.
- From the dropdown menu, select new datasource.
- Under the first tab "Database" > JDBC driver files > select MySQL Connector/(some ver) > "Click here to download".
-
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
Config your database access credentials.
- If you don't have any existing db, then goto PhpMyAdmin to manually setup a new db and create new users with access credentials.
- Now back in PhpStorm, simply key in the same access credentials.
- Once your configurations are done correctly, you should see the database window populated by a list of your db tables.
- 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.
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