Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
vms:webdev:phpfarm:xdebug [2014/11/03 14:42]
admin [Activate for the Specific PHP Version]
vms:webdev:phpfarm:xdebug [2016/11/29 18:38]
admin [Setting up Xdebug’s remote debug with Atom (1.12.5)]
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]]+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 ====
 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: 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>​ <​code>​
-> sudo nano /​opt/​phpfarm/​inst/​php-5.4.4/​etc/php.ini+> sudo nano /​opt/​phpfarm/​inst/​php-5.4.4/​lib/php.ini
  
 ; remote debug ; remote debug
Line 104: Line 124:
 xdebug.remote_connect_back=1 xdebug.remote_connect_back=1
 xdebug.max_nesting_level=200 xdebug.max_nesting_level=200
 +
 +SAVE (ctrlX - y)
 +
 +> sudo service apache2 restart
 +
 </​code>​ </​code>​
  
Line 111: Line 136:
 Open your PhpStorm settings (ctrl-alt-s),​ and select **Project'​s Settings > PHP > Debug**.\\ 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). 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 |}}+{{ :vms:webdev:​phpstorm-xdebug-port.png?​direct&​200 |}}
 \\ \\
 Save those settings and now go to "Run > Edit Configurations"​ Save those settings and now go to "Run > Edit Configurations"​
-{{ :packages:amp:​php:​xdebug:​phpstorm-xdebug-runconf.jpg?​direct&​200 |}}+{{ :vms:webdev:​phpstorm-xdebug-runconf.jpg?​direct&​200 |}}
 \\ \\
 Then create a new PHP Remote Debug configuration:​ Then create a new PHP Remote Debug configuration:​
-{{ :packages:amp:​php:​xdebug:​phpstorm-xdebug-createremote.png?​direct&​200 |}}+{{ :vms:webdev:​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.\\ 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: 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 |}} +{{ :vms:webdev:​phpstorm-xdebug-webdevvm1.png?​direct&​200 |}} 
-{{ :packages:amp:​php:​xdebug:​phpstorm-xdebug-webdevvm2.png?​direct&​200 |}}+{{ :vms:webdev:​phpstorm-xdebug-webdevvm2.png?​direct&​200 |}}
 \\ \\
 Now put some breakpoints in your php code by clicking in the left margin: Now put some breakpoints in your php code by clicking in the left margin:
-{{ :packages:amp:​php:​xdebug:​phpstorm-xdebuf-breakpoint.png?​direct&​200 |}}+{{ :vms:webdev:​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): 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 |}} +{{ :vms:webdev:​phpstorm-xdebug-turnon.png?​direct&​200 |}} 
-{{ :packages:amp:​php:​xdebug:​phpstorm-xdebug-on.png?​direct&​200 |}}+{{ :vms:webdev:​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. Accessing this script by loading the page in your browser should now stop execution at the breakpoints you placed.
Line 139: Line 164:
  
 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! 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!
 +
 +----
 +===== 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 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
 +
 +
 +