Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Xdebug with the built in PHP test server?

Tags:

php

debugging

Basically my question says it all.

I'd like to be able to inspect the state of the variables of my script, set breakpoints etcétera, without the need to install Nginx, apache or PHP-FPM?

Is this doable, if not what would be my options?

like image 344
Tristian Avatar asked Dec 16 '14 02:12

Tristian


1 Answers

Ok so parting from this article I've managed to use xdebug.

I installed PHP 5.5 on Mac OS X 10.10 using homebrew


  1. Install PHP if it has not been installed, make sure to install it with the xdebug extension;
    in my case I used$ brew install php55-xdebug or if you have pecl and php already installed use $ pecl install xdebug.
    You can check if the extension is installed by executing $ php -m | grep xdebug.

  2. If you use VIM as your "IDE", I'd recommend to install the vim pathogen plugin, then install the xdebugger vim plugin; which I've modified to be pathogen compatible.

    $ cd ~/.vim/bundle && git clone https://github.com/Triztian/xdebugger.git

  3. Next we have to enable the xdebugger extension; to do so first you need to find out which php.ini file is being loaded, you can check that by running $ php -i | grep "File => /". After you've found the correct init file you must add the follwing lines at the end:

    xdebug.remote_enable=On
    xdebug.remote_autostart=On

    If using PHP's built-in development server, you can use the -c argument to specify a php.ini file.

  4. Now, start the php development server (in my case $ php -S localhost:8080 -c /usr/local/etc/php/5.5/php.ini) and open VIM. After VIM is open press <f5> so that the xdebugger starts listening for a connection; on your browser navigate to localhost:8080/index.php (or any php script) so that it triggers the xdebugger connection if everything has been setup correctly.

  5. You should no be in a debugging session, look at the plugin's readme to see how it works.

like image 142
Tristian Avatar answered Nov 07 '22 14:11

Tristian