start debugging

with Xdebug

You all know Xdebug ?

Please say yes!

Install xdebug

I'm going to assume you are debugging on a remote linux machine

debian/ubuntu

$ apt-get install php5-xdebug

redhat/centos

$ yum install php-pecl-xdebug

archlinux

$ pacman -S xdebug

Configure xdebug

debian/ubuntu

$ vim /etc/php5/mods-available/xdebug.ini

redhat/centos

$ vim /etc/php.d/xdebug.ini

archlinux

$ vim /etc/php/conf.d/xdebug.ini

Configure xdebug

1 zend_extension=xdebug.so
2 xdebug.remote_enable = 1
3 xdebug.remote_connect_back = 1
4 xdebug.remote_autostart = 0
5 xdebug.remote_port = 9000
6 xdebug.remote_host = 192.168.254.1

Debugging

Default actions

  • step over
  • step into
  • step out
  • run to cursor
  • setting a breakpoint

vim / vdebug

install the vdebug plugin in your vim installation and you're good to go

1 let g:vdebug_options["port"] = 9000
2 let g:vdebug_options["server"] = '192.168.254.1'
3 let g:vdebug_options["path_maps"] = {'/var/www/website': '/home/devolderi/github/Laravel-5-Bootstrap-3-Starter-Site'}

phpstorm

You can start debugging without configuration in phpstorm, it will ask for the settings when the first connection comes in

 74   <component name="PhpServers">
 75     <servers>
 76       <server host="laravelstarter.dev" id="364d642d-d806-4c19-b80a-2e623747a2a1" name="laravelstarter.dev" use_path_mappings="true">
 77         <path_mappings>
 78           <mapping local-root="$PROJECT_DIR$" remote-root="/var/www/website" />
 79           <mapping local-root="$PROJECT_DIR$/public" remote-root="/var/www/website/public" />
 80         </path_mappings>
 81       </server>
 82     </servers>
 83   </component>

$project/.idea/workspace.xml

start a debug session

you can start a debug session for a cli script by setting the XDEBUG_CONFIG environment variable

$ XDEBUG_CONFIG="something" php myscript.php

when starting a session from a browser we must set XDEBUG_SESSION="myide" in your cookie

lets debug with vim

lets debug with phpstorm

phpstorm support thx to @Pegasuz_

Thanks.

https://joind.in/15167

joindin qr

Ike Devolder

@BlackIkeEagle

Senior Webdeveloper - Studio Emma

PHP-WVL

Archlinux Trusted User

studioemma
php-wvl
archlinux