How to install XDebug in PhpStorm

From Cosmin's Wiki

Jump to: navigation, search

Home > Mac OSX > How to install XDebug in PhpStorm


Installing XDebug

What I have done, as a big fan of MacPort, was to simply run:

> sudo port install php54-xdebug

which will take care of the full installation of XDebug on your machine

After this installation, xdebug will create a .ini file under
/opt/local/var/db/php54/xdebug.ini

Customizing XDebug

First of all, you need to disable the Zend optimizer, which will block XDebug. For that, locate the following section in your php.ini file and comment it out:

 
[Zend]
zend_extension_ts = "<path to ZendExtensionManager.dll>"
zend_extension_manager.optimizer_ts = "<path to Zend Optimizer>"
zend_optimizer.enable_loader = 0
zend_optimizer.optimization_level=15
zend_optimizer.license_path =
Local Variables:
tab-width: 4
End:

Now, all you need to do is add to php.ini the following section

 
[XDebug]
xdebug.remote_enable=0
xdebug.remote_port="9000"
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/some/path/here"
 

You can test the installation on this page: XDebug Wizard

PhpStorm settings

  1. Open the Project Settings and click PHP.
  2. On the PHP page that opens, click the Browse button browseButton next to the Interpreter drop-down list.
  3. In the Interpreter dialog box that opens, choose XDebug from the Debugger drop-down list.
  4. Define the XDebug behaviour. Click Debug under the PHP node. On the Debug page that opens, specify the following settings in the XDebug area:
    • In the Debug Port text box, appoint the port through which the tool will communicate with PhpStorm. This must be exactly the same port number as specified in the php.ini file:
      xdebug.remote_port = <port_number>
    • By default, Xdebug listens on port 9000.
    • To have PhpStorm accept any incoming connections from XDebug engines through the port specified in the Debug port text box, select the Can accept external connections check box.
    • To have addresses of variables shown during a debugging session, select the Show variables addresses check box.
    • To have PhpStorm apply a workaround to overcome a known XDebug on FreeBSD crash issue, select the Enable workaround for [XDebug on FreeBSD crash] check box.
  5. To have XDebug stop as soon as connection between it and PhpStorm is established (instead of running automatically until the first breakpoint is reached), turn on the Run | Break at first line in PHP scripts option on the main menu.

Complete details for this can be found on the PhpStorm website