The phpStorm 7 IDE is an excellent tool to write your PHP code in. This post describes the step to take to debug your PHP website with phpStorm 7 and XDebug. This post only describes the installation of XDebug and the use of phpStorm 7. You can also find posts about installing Apache and Mysql on this blog.
First of all download a copy of phpStorm 7 and unpack it to a directory of your choice. PhpStorm 7 depends on java so you should also install java onto your system.
Next thing to do is configure XDebug and Apache to work together. First step is to determine the active php.ini . This can easily be done by creating a PHP script with a call to phpinfo();.
Copy the contents of this page (not the page source) and paste it into the textbox found at http://xdebug.org/wizard.php.
Download the XDebug archive at http://xdebug.org/files/xdebug-2.2.3.tgz. Unzip the archive with
tar -xzvf xdebug-2.2.3.tgz
Goto the directory created by the unzip command:
cd to xdebug-2.2.3
Run the phpize command (prepare PHP extension for compiling); the output should be something like:
$>phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525
When you see something like the text above you know you’re good to go.
Execute ./configure to configure the make script
When configure runs ok execute the make command:
After the make command has finished you have a compiled xdebug.so module in the modules directory.
Copy the xdebug.so module to /usr/lib/php5/[Zend Extension value from phpinfo(); call]
Now in the output of the phpinfo() call search for the value Loaded Configuration File. The second column shows the active php.ini . Edit this file and add the lines below (uncomment any [zend] section if it exists):
[XDebug] zend_extension="/usr/lib/php5/20100525/xdebug.so" xdebug.remote_enable=1 xdebug.remote_port=9000 xdebug.profiler_enable=1 xdebug.profiler_output_dir="/tmp>"
Change the location of zend_extension as needed!
Restart your apache server:
sudo service apache2 restart
Rerun your phpinfo() script and paste it again into the textbox at http://xdebug.org/wizard.php
Check for a line that says something like “You’re already running the latest Xdebug version “, If it is there you have configured PHP to use the XDebug extension.
Now it is time to startup phpStorm 7 and create our first PHP project. Start your copy of phpStorm 7.
Select “Create New Project” (choose “Empty project for now; be sure that the location is in or below the DocumentRoot of your apache site) and follow the steps below:
- Add a new file index.php and add a call tophpinfo() to it (right click the project title on the left; select New -> PHP File).
- Select Run -> Edit configurations
- Select the + sign at the top left and select “Php Web Application”
- Name it for example “WebAppDebugConfig”
- Press the “…” after “Server” to add a server.
- Press the + sign at the top left.
- Change the servername to the name of your development host (both Name and Host) and press Ok
- Select the Server Name in the “Run/Debug Configurations” to make the error go away
- Fill out your start URL; /index.php
- Press Ok