Jump to content


Photo

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


  • Please log in to reply
14 replies to this topic

#1 renatov

renatov

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 22 February 2014 - 07:23 PM

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.



#2 renatov

renatov

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 25 February 2014 - 10:25 AM

No one debugs PHP?



#3 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,731 posts
  • LocationBonita, FL

Posted 25 February 2014 - 12:29 PM

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.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#4 renatov

renatov

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 25 February 2014 - 01:45 PM

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



#5 gizmola

gizmola

    Advanced Member

  • Administrators
  • 4,137 posts
  • LocationLos Angeles, CA USA

Posted 25 February 2014 - 06:05 PM

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.

#6 renatov

renatov

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 25 February 2014 - 10:44 PM

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...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?



#7 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,678 posts
  • LocationMississauga, Canada

Posted 25 February 2014 - 10:45 PM

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.



#8 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,731 posts
  • LocationBonita, FL

Posted 25 February 2014 - 11:58 PM

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.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#9 renatov

renatov

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 26 February 2014 - 10:04 AM

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.



#10 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,731 posts
  • LocationBonita, FL

Posted 26 February 2014 - 11:05 AM

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.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#11 gizmola

gizmola

    Advanced Member

  • Administrators
  • 4,137 posts
  • LocationLos Angeles, CA USA

Posted 26 February 2014 - 05:13 PM

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.

#12 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,678 posts
  • LocationMississauga, Canada

Posted 26 February 2014 - 05:50 PM

 

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. 



#13 renatov

renatov

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 26 February 2014 - 06:58 PM

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



#14 trq

trq

    Advanced Member

  • Administrators
  • 31,031 posts
  • LocationSydney, Australia.

Posted 27 February 2014 - 06:29 AM

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


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

http://thorpesystems...ging-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.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.


#15 renatov

renatov

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 27 February 2014 - 01:11 PM

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

http://thorpesystems...ging-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!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com