Jump to content
Sign in to follow this  
renatov

How do you debug php? Which debugger do you use?

Recommended Posts

I've found some debugger options for PHP:

 

http://xdebug.org/

http://www.php-debugger.com/dbg/

http://phpdbg.com/

http://dbug.ospinto.com/

http://www.firephp.org/

http://pecl.php.net/package/apd

 

And probably there are more. Do you guys know any of these debuggers? Do you recommend one? What is the best PHP debugger?

 

ps: I'm trying to avoid IDEs at the momment, I would like to use a tool specifically made for debugging.

Share this post


Link to post
Share on other sites

No one debugs PHP?

Probably more likely is people debug with their IDE's but you said you don't want an IDE so there's not much to say.

 

For step-through logic debugging I use PHPStorm with XDebug. For quicker informational debugging I just scatter some var_dumps around the code.

Share this post


Link to post
Share on other sites

I see, thanks for your reply. Is it possible to use XDebug outside an IDE? Like, via terminal.

Share this post


Link to post
Share on other sites

You can hook up xdebug to a lot of different editors. With that said, in order for a debugger to work, you need some sort of editor to load code and display it for step through. Most people are using one of the more popular PHP IDE's (PHPStorm, Eclipse PDT/Zend Studio/ Netbeans, etc) and understanding how xdebug works and what you have to do to utilize it isn't exactly point and click, depending on your development setup.

 

For example, I wrote an article on how to get things setup with Eclipse/PDT some years ago, and it's not the easiest thing in the world to get started with. Take a look at it if you're interested.

Share this post


Link to post
Share on other sites

I find a plugin for Sublime Text that aparently can enable XDebug inside this text editor. What I need for PHP is something like pudb (for Python), take a look at this pudb print screen:

 

http://asmeurersympy.files.wordpress.com/2010/07/screen-shot-2010-07-28-at-12-51-36-pm.png

 

It runs on terminal and it has these features:

 

1. Execute line by line

2. Show variables values and changes line by line

3. Enable you to navigate between functions stack

4. Can use breakpoints

 

Does XDebug offer this? Is there another debugger for PHP that has these features?

Share this post


Link to post
Share on other sites

I find XDebug as not very efficient for myself when I follow object oriented design patterns in my code. It could be very powerful and useful if you're coding in procedural way with bad coding design. I am on Netbeans IDE which is absolutely enough for what I want to do and Vi/VIM as command line  interface code editor.

Share this post


Link to post
Share on other sites

Does XDebug offer this? Is there another debugger for PHP that has these features?

XDebug itself doesn't provide any kind of interface for actually interacting with the script. That is the job of a third-party client like your text editor or IDE. On the XDebug website they have a list of clients that will provide this functionality. In the list there is:

XDebugClient - Standalone Windows client.

If you're not using windows, then look at the list for other possible clients. If you feel comfortable with a compiler, the xdebug source package includes a simple client you can compile and use.

  • Like 1

Share this post


Link to post
Share on other sites

I find XDebug as not very efficient for myself when I follow object oriented design patterns in my code. It could be very powerful and useful if you're coding in procedural way with bad coding design. I am on Netbeans IDE which is absolutely enough for what I want to do and Vi/VIM as command line  interface code editor.

 

Why isn't XDebug suitable for debuggin Object Oriented PHP?

 

 

XDebug itself doesn't provide any kind of interface for actually interacting with the script. That is the job of a third-party client like your text editor or IDE. On the XDebug website they have a list of clients that will provide this functionality. In the list there is:

 

If you're not using windows, then look at the list for other possible clients. If you feel comfortable with a compiler, the xdebug source package includes a simple client you can compile and use.

 

I'm on Linux and I'm totally comfortable with compiling. How is this simple xdebug client included in the source package? I couldn't find any information about it.

Share this post


Link to post
Share on other sites

How is this simple xdebug client included in the source package? I couldn't find any information about it.

I have no idea, never used it. Compile it and try it, probably wont take more than a few minutes.

Share this post


Link to post
Share on other sites

They have a Vim plugin. You can run vim in the terminal. Why not just use that? There are also extensions for chrome, firefox and safari.

Share this post


Link to post
Share on other sites

 

Why isn't XDebug suitable for debuggin Object Oriented PHP?

B/s the main purpose of using XDebug is to brake down your script into small pieces and fragments of data making it much more easy to debuging. By using OO design patterns, that's guarantee (in most cases) that, that data it's encapsulating within a set of functions designed to ensure that the scripts are used appropriately and in a human readable format. 

Share this post


Link to post
Share on other sites

Ok, thanks guys! I'll try using Xdebug with Sublime Text and with VIM to see if it offers what I'm looking for.

Share this post


Link to post
Share on other sites

It is. I use it on a daily basis with a few large Symfony2 based applications. It's a great tool.

 

http://thorpesystems.com/blog/debugging-php-in-vim

 

I'm pretty interested in taking a look at http://phpdbg.com one of these days too as it ships with PHP5.6.

 

Yes, I was interested in learning phpdbg too since it will be in PHP 5.6 core, but it seems xdebug is better documented, so I'll give it a try at least for now. Thanks for your tutorial!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.