Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
vms:webdev:phpfarm:xdebug [2015/05/05 16:47] admin [Setting up Xdebug’s remote debug with PHPStorm] |
vms:webdev:phpfarm:xdebug [2016/11/29 23:58] admin [Install Package php-debug (0.2.4)] |
||
---|---|---|---|
Line 9: | Line 9: | ||
XDebug can be [[http://xdebug.org/download.php|downloaded in a variety of versions]] or even built from [[https://github.com/derickr/xdebug|sources]]. | XDebug can be [[http://xdebug.org/download.php|downloaded in a variety of versions]] or even built from [[https://github.com/derickr/xdebug|sources]]. | ||
- | Although the easier way to get it running is using Xdebug's website [[http://xdebug.org/wizard.php|installation wizard]] that will help you determine what to do to get XDebug working on your system. Follow the simple instructions and you'll soon have XDebug installed and running. | + | Although the easiest way to get it running is using Xdebug's website [[http://xdebug.org/wizard.php|installation wizard]] that will help you determine what to do to get XDebug working on your system. Follow the simple instructions and you'll soon have XDebug installed and running. |
First refer to [[vms:webdev:apache#make_sure_everything_is_running as_expected|this section of the wiki]] to have PHP output it's configuration summary, and copy/paste it in the above mentioned [[http://xdebug.org/wizard.php|XDebug wizard]]. | First refer to [[vms:webdev:apache#make_sure_everything_is_running as_expected|this section of the wiki]] to have PHP output it's configuration summary, and copy/paste it in the above mentioned [[http://xdebug.org/wizard.php|XDebug wizard]]. | ||
Line 88: | Line 88: | ||
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". | ||
+ | |||
+ | ===== Configuring Apache fcgid Timeout ===== | ||
+ | |||
+ | Running Xdebug will often suspend your scripts execution for a longer period than the default, 40 sec, mod_fcgid read data timeout. That will result in your browser throwing a "500 - Internal Server Error" before you complete the debugging session, also suspending debugging possibilities. | ||
+ | |||
+ | We'll increase the timeout limits by editing the following configuration parameter in **/etc/apache2/mods-available/fcgid.conf** | ||
+ | <code> | ||
+ | > nano /etc/apache2/mods-available/fcgid.conf | ||
+ | |||
+ | ADD: | ||
+ | ... | ||
+ | FcgidConnectTimeout 20 | ||
+ | FcgidIOTimeout 300 | ||
+ | ... | ||
+ | </code> | ||
+ | |||
+ | Don't forget to restart the apache2 service to apply those changes: | ||
+ | <code> | ||
+ | > service apache2 restart | ||
+ | </code> | ||
===== Setting up Xdebug’s remote debug with PHPStorm ===== | ===== 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]] and [[https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html|this article from JetBrains]] | + | Based on [[http://www.irving-swift.com/2014/01/setting-up-xdebugs-remote-debug-with-phpstorm|this article by James Irving-Swift]] and [[https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html|this article from JetBrains]] |
==== Edit Your php.ini File ==== | ==== Edit Your php.ini File ==== | ||
Line 147: | Line 167: | ||
---- | ---- | ||
===== Setting up Xdebug’s remote debug with InteeliJ IDEA (14.1.1) ===== | ===== Setting up Xdebug’s remote debug with InteeliJ IDEA (14.1.1) ===== | ||
- | ---- | + | |
+ | === PHP Remote Interpreter plugin: === | ||
+ | |||
+ | **Settings** (Ctrl-Alt-S) **> Plugins > Install JetBrains Plugin...** (button) **> Search** (PHP Remote Interpreter) **> Install plugin** (button) | ||
+ | |||
+ | Then restart IntelliJ IDEA | ||
+ | |||
+ | === PHP Interpreter === | ||
+ | |||
+ | **Settings** (Ctrl-Alt-S) **> Languages & Frameworks > PHP** | ||
+ | |||
+ | Select desired PHP language level.\\ | ||
+ | Interpreter: click "..." button, then green "+" button > Remote... | ||
+ | |||
+ | Enter SSH Credentials, then "..." button next to PHP interpreter path:\\ | ||
+ | Select desired php executable (ex: /opt/phpfarm/inst/php-5.5.23/bin/php) | ||
+ | |||
+ | === XDebug config === | ||
+ | |||
+ | **Settings** (Ctrl-Alt-S) **> Languages & Frameworks > PHP > Debug** | ||
+ | |||
+ | Make sure the Xdebug port is set to the same port as specified in your php.ini file (default: 9000). | ||
+ | |||
+ | === Debug Configuration === | ||
+ | |||
+ | From top right icons menu of main IntelliJ IDEA's project window, use "down arrow" button (Select Run/Debug configuration), then "Edit configurations..."\\ | ||
+ | |||
+ | |||
+ | ===== Setting up Xdebug’s remote debug with Atom (1.12.5) ===== | ||
+ | |||
+ | === Install Atom Package php-debug (0.2.4) === | ||
+ | * Open the Atom editor and open settings: Edit > Preferences (ctrl-,) | ||
+ | * Select "Install" from the left menu | ||
+ | * Type "php-debug" in Search packages field, then //return// to launch the search | ||
+ | * php-debug should appear on top of the list, click the "Install" button | ||
+ | * Read the README that is displayed | ||
+ | |||
+ | === Configure Xdebug === | ||
+ | You have to configure Xdebug for the specific PHP version that you want to debug with, so you'll have to adapt the following with the corresponding location. | ||
+ | |||
+ | In this case we'll configure our PHP version 5.6.27 to debug from Atom. First we'll edit our ''php.ini'' file: | ||
+ | |||
+ | <code> | ||
+ | > sudo nano /opt/phpfarm/inst/php-5.6.27/lib/php.ini | ||
+ | |||
+ | PASTE AT EOF (removing any existing [xdebug] lines): | ||
+ | [xdebug] | ||
+ | zend_extension = "/opt/phpfarm/inst/php-5.6.27/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so" | ||
+ | xdebug.profiler_output_dir = "/tmp/xdebug" | ||
+ | xdebug.trace_output_dir = "/tmp/xdebug" | ||
+ | ; additional settings (atom) | ||
+ | xdebug.remote_enable=1 | ||
+ | xdebug.remote_handler=dbgp | ||
+ | xdebug.remote_mode=req | ||
+ | xdebug.remote_host=172.20.20.2 | ||
+ | xdebug.remote_port=9000 | ||
+ | xdebug.idekey=xdebug.atom | ||
+ | xdebug.remote_autostart=true; | ||
+ | xdebug.collect_params=4 | ||
+ | xdebug.collect_vars=on | ||
+ | xdebug.show_local_vars=on | ||
+ | |||
+ | > sudo service apache2 restart | ||
+ | </code> | ||
+ | |||
+ | To make sure those values have been taken into account, load the phpinfo page created earlier and check the //**xdebug**// section to make sure the displayed values are in concordance with the ones you've introduced in the ''php.ini'' file. | ||
+ | |||
+ | With these settings, PHP will **connect to your editor for every script it executes**. The alternative is to use ''xdebug.remote_autostart=false'', and install an Xdebug helper extension for your browser of choice, such as: | ||
+ | * [[https://addons.mozilla.org/en-US/firefox/addon/the-easiest-xdebug/|The easiest Xdebug for Mozilla Firefox]] | ||
+ | * [[https://chrome.google.com/webstore/detail/xdebug-helper|Xdebug Helper for Google Chrome]] | ||
+ | |||
+ | These browser extensions will give you a button within your browser to enable/disable Xdebug. |