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?
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
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
.
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
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.
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.
You should no be in a debugging session, look at the plugin's readme to see how it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With