22 October 2013

How to install Xdebug with Sublime Text in Ubuntu 12.04

15 comments

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

You May Also Like...

15 comments:

  1. Hello. I have tried to run "start debugging(launch browser)", but browser not opening.
    What is wrong? May be i need to add something to php.ini?
    I have just this: https://db.tt/9N367hd2

    My system is Elementary OS Luna (based on ubuntu 12.04).
    Please, help me. :)

    ReplyDelete
    Replies
    1. Please check whether you have installed xdebug client or Xdebug plugin. If you have installed xdebug then uninstall it and install xdebug client.
      Sorry for late reply

      Delete
    2. I have installed XDebug Client, but it doesn't work. :(

      Delete
    3. Sorry then i have no idea why it is not working in your system

      Delete
  2. If you are using a separate system to trigger the calls, do not enable remote callback. Instead, your settings could look like this:

    xdebug.remote_autostart = 1
    xdebug.remote_enable = 1
    xdebug.remote_handler = dbgp
    xdebug.remote_host = 127.0.0.1
    xdebug.remote_log = /tmp/xdebug_remote.log
    xdebug.remote_mode = req
    xdebug.remote_port = 9001

    ReplyDelete
  3. If you are looking for the Software Engineering Help assignment then in this case you can opt for our Essay Writing.we provide the best online assignment help.We also provide law essay help for students across the globe. for more information contact us +16692714848.


    ReplyDelete
  4. Many blogs like this cover subjects that just aren’t covered by magazines.
    offshoreservers.net

    ReplyDelete
  5. Assignment and Homework Help in Toronto
    Thetutorshelp.com Students face lots of issues once it involves writing as some aren't as delicate because of the others. Assignment and Homework Help in Toronto This might result in a lack of confidence, a lack of grounding, and more. No matter perhaps the rationale, they cannot escape the task of writing. See more -https://www.thetutorshelp.com/assignment-help-toronto.php

    ReplyDelete
  6. Assignment Help in Ottawa
    We offer nursing assignment help USA and Nursing Assignment Help in Ottawa, Toronto, Montreal, Boston,. Get 60% OFF. Enroll now For more information mail us on info@thetutorshelp.com https://www.thetutorshelp.com/assignment-help-in-ottawa.php

    ReplyDelete
  7. Assignment Help Hamilton
    We aim to help you with your grades and assist you in every possible way so that you have an exceptional career ahead. Our prices are fair and low so that every student can avail of it without any difficulty. Assignment Help Hamilton We also provide infinite changes to the assignment if it doesn’t matchyour requirements https://www.thetutorshelp.com/assignment-help-hamilton.php

    ReplyDelete
  8. Excellent blog again, thanks so much! It's an excellent blog with an interesting topic. By using this, you can be sure your face will be seen properly and that the lighting is appropriate. The information presented in this article o Test Webcam on Windows 10 Laptop or Desktop Offline
    will help you to be professional and to make your video communication successful.

    ReplyDelete