Anda di halaman 1dari 2

Xdebug is a PHP extension for powerful debugging.

It supports stack and function


traces, profiling information and memory allocation and script execution analysis.
Xdebug provide following functionality like function name, file name and line
indications, support for member functions, full parameter display for user defined
functions etc for PHP developers which help them to debug their code easily and
quickly.

Installing Xdebug with Sublime Text in Ubuntu is little bit tricky, but you can
easily install it if you follow along this post. Lets get started.

Installing Xdebug in Ubuntu


Step 1: Open terminal(Ctrl + Alt + t) and type following command to see whether
Xdebug is installed or not.

$ php -v
PHP 5.3.10-1ubuntu3.8 with Suhosin-Patch (cli) (built: Sep 4 2013 20:00:51)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Note: If your Output is same like mine then you are good to go. If not the type
following command to install it.

$ sudo apt-get install php5-xdebug

Step 2: Find the location of "xdebug.so" using following commad

$ sudo find /usr/lib/php5 -name 'xdebug.so'


/usr/lib/php5/20090626/xdebug.so

Note: If you don't find the path of the file using the above command, use following
command to search in entire file system

$ sudo find / -name 'xdebug.so'

Step 3: Next step is to edit xdebug.ini file using the following commands

$ cd /etc/php5/apache2/conf.d
$ sudo gedit xdebug.ini

Add following lines to xdebug.ini file

zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.profiler_enable_trigger=On
xdebug.profiler_output_dir=/tmp
xdebug.max_nesting_level = 200
xdebug.remote_connect_back = 1

Note:In zend_extension field enter your xdebug.so file path. If you want to know
what all this means, you can refer Xdebug official website.

Step 4: Restart your apache web-server


$ sudo service apache2 restart

Integrating Xdebug with Sublime Text


We successfully installed Xdebug in Ubuntu, lets integrate it with sublime text

Step 1: Open Sublime text, open package manager (Ctrl + shift + p), type install
packages and select xdebug client.

Step 2: Next step is to edit xdebug configuration file. Go to tools->xdebug-


>default setings and in url field enter the url which you want to debug.

Step 3: Add break point and start debugger using start debugging(launch browser)
option.

That's it. Happy Debugging.


Enjoy :)

If You Liked This Post Please Take a Time To Share This Post

1205

0
Reddit
0
Delicious
16
Google +
1

35
Blogger
0
StumbleUpon

Anda mungkin juga menyukai