A PCRE internal error occured. This might be caused by a faulty plugin
====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
packages:amp:php:xdebug [2014/01/02 00:51] admin [Testing your XDebug] |
packages:amp:php:xdebug [2014/09/26 19:13] (current) admin [Configure PhpStorm] |
||
---|---|---|---|
Line 3: | Line 3: | ||
===== XDebug With Phpfarm ===== | ===== XDebug With Phpfarm ===== | ||
- | When using Phpfarm, XDebug has to be installed separately for each version. Hereunder are the explanation on how to do this, you'll have to repeate the process for each version of PHP you've installed. | + | When using Phpfarm, XDebug has to be installed separately for each version. Hereunder are the explanation on how to do this, you'll have to repeat the process for each version of PHP you've installed. |
Quite obviously, you'll have to adapt the version number in the examples to fit your situation. | Quite obviously, you'll have to adapt the version number in the examples to fit your situation. | ||
Line 13: | Line 13: | ||
mkdir /opt/phpfarm/xdebug | mkdir /opt/phpfarm/xdebug | ||
cd /opt/phpfarm/xdebug | cd /opt/phpfarm/xdebug | ||
- | wget http://xdebug.org/files/xdebug-2.2.3.tgz | + | wget http://xdebug.org/files/xdebug-2.2.5.tgz |
- | tar -xzf xdebug-2.2.3.tgz | + | tar xzf xdebug-2.2.5.tgz |
- | cd xdebug-2.2.3 | + | cd xdebug-2.2.5 |
</code> | </code> | ||
Line 33: | Line 33: | ||
sudo make | sudo make | ||
sudo make install | sudo make install | ||
+ | </code> | ||
+ | |||
+ | In case you get an error like:\\ | ||
+ | Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script\\ | ||
+ | You'll have to install autoconf: | ||
+ | <code> | ||
+ | > sudo apt-get install autoconf | ||
</code> | </code> | ||
Line 44: | Line 51: | ||
sudo nano /opt/phpfarm/inst/php-5.5.7/lib/php.ini | sudo nano /opt/phpfarm/inst/php-5.5.7/lib/php.ini | ||
----- add this at EOF ----- | ----- add this at EOF ----- | ||
- | zend_extension="opt/phpfarm/inst/php-5.5.7/lib/php/extensions/debug-non-zts-20121212/xdebug.so" | + | zend_extension="/opt/phpfarm/inst/php-5.5.7/lib/php/extensions/debug-non-zts-20121212/xdebug.so" |
xdebug.profiler_output_dir = "/tmp/xdebug" | xdebug.profiler_output_dir = "/tmp/xdebug" | ||
xdebug.trace_output_dir = "/tmp/xdebug" | xdebug.trace_output_dir = "/tmp/xdebug" | ||
- | xdebug.remote_enable=1 | ||
- | xdebug.remote_port=9000 | ||
- | | ||
- | xdebug.idekey=PhpStrom | ||
- | xdebug.remote_connect_back=1 | ||
; additional settings | ; additional settings | ||
Line 68: | Line 70: | ||
===== Testing your XDebug ===== | ===== Testing your XDebug ===== | ||
To make sure XDebug is working, you can check the phpinfo(); output that you initialy used to feed the wizard. Reloading the page should now contain an "xdebug section". | To make sure XDebug is working, you can check the phpinfo(); output that you initialy used to feed the wizard. Reloading the page should now contain an "xdebug section". | ||
+ | |||
+ | ===== Setting up Xdebug’s remote debug with PHPStorm ===== | ||
+ | Based on [[http://www.irving-swift.com/2014/01/setting-up-xdebugs-remote-debug-with-phpstorm/|this article by James Irving-Swift]] | ||
+ | |||
+ | ==== Edit Your php.ini File ==== | ||
+ | As we already did in the previous step on this page, we edit our php.ini file to enable XDebug's remote debugging feature. Add the following at the end of the file: | ||
+ | <code> | ||
+ | > sudo nano /opt/phpfarm/inst/php-5.4.4/lib/php.ini | ||
+ | |||
+ | ; remote debug | ||
+ | xdebug.remote_enable=1 | ||
+ | xdebug.remote_host=172.20.20.1 | ||
+ | xdebug.remote_port=9000 | ||
+ | xdebug.idekey="PHPSTORM" | ||
+ | xdebug.remote_autostart=1 | ||
+ | xdebug.remote_connect_back=1 | ||
+ | xdebug.max_nesting_level=200 | ||
+ | </code> | ||
+ | |||
+ | ==== Configure PhpStorm ==== | ||
+ | (this is for PhpStorm version 7) | ||
+ | |||
+ | Open your PhpStorm settings (ctrl-alt-s), and select **Project's Settings > PHP > Debug**.\\ | ||
+ | Make sure your Xdebug port is set to the same value as was entered in your php.ini file (here the default 9000). | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebug-port.png?direct&200 |}} | ||
+ | \\ | ||
+ | Save those settings and now go to "Run > Edit Configurations" | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebug-runconf.jpg?direct&200 |}} | ||
+ | \\ | ||
+ | Then create a new PHP Remote Debug configuration: | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebug-createremote.png?direct&200 |}} | ||
+ | \\ | ||
+ | Give this configuration whatever name you see fit, but just make sure the IDE key matches what is in your server's php.ini file, here we use PHPSTORM.\\ | ||
+ | You'll also have to specify a server, you can do this by typing the "..." button next to <no server>, we'll specify our webdev's server IP address and map our local files to the remote server's project root: | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebug-webdevvm1.png?direct&200 |}} | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebug-webdevvm2.png?direct&200 |}} | ||
+ | \\ | ||
+ | Now put some breakpoints in your php code by clicking in the left margin: | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebuf-breakpoint.png?direct&200 |}} | ||
+ | \\ | ||
+ | Turn on Xdebug listening by clicking on the appropriate button (it will change icon to indicate it's listening or not): | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebug-turnon.png?direct&200 |}} | ||
+ | {{ :packages:amp:php:xdebug:phpstorm-xdebug-on.png?direct&200 |}} | ||
+ | |||
+ | Accessing this script by loading the page in your browser should now stop execution at the breakpoints you placed. | ||
+ | |||
+ | |||
+ | ==== Some Practical Advices ==== | ||
+ | |||
+ | When you are not using xdebug, James Irving-Swift highly recommends that you turn it off on your server, as if your computer is turned off and you access anything that runs PHP via your webserver it will hang as it will be looking for the machine with the IP address specified! | ||
+ | |||
+ | He also recommends that you check out xdebug’s profiler if you haven’t already and use it with a tool like kcachegrind or webgrind. Again, it's recommended that you should turn off profiling when not using it as the files it creates on each page load are vast, you may find you run out of storage very quickly! |