Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Equivalent for Python PDB(Debugger) in PHP? [closed]

I'm essentially a PHP coder that started to code some things in Python. I'm amazed with Python PDB, there is something equivalent to PHP?

I'm working with a PHP Web Framework and I'd like specially of the pdb.set_trace() that is very useful when we are working with a web framework in Python.

My question is, there is something equivalent for PHP?

like image 715
André Avatar asked Nov 22 '11 11:11

André


People also ask

How do I debug Python code using pdb?

To start debugging within the program just insert import pdb, pdb. set_trace() commands. Run your script normally and execution will stop where we have introduced a breakpoint. So basically we are hard coding a breakpoint on a line below where we call set_trace().

Can PHP be debugged?

A: You can easily debug PHP in Chrome using a simple extension called PHP Console. Just install this PHP debugging tool from the Chrome web store and start logging errors, warnings, exceptions, and vars dump on your Chrome browser.

What should I debug PHP with?

A: You can debug PHP code in Firefox using multiple debugging tools. Firefox provides an extension for popular PHP debugging tools including FirePHP, Xdebug, Firebug, and others.

Is pdb a debugging module in Python?

The module pdb defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame.


2 Answers

If you are using an IDE, then it should have built in debugging functions for stepping into, over code and the usual suite of functions. I use Zend Studio myself.

Having said that, I have used the following:

  • var_dump to dump variables and objects
  • debug_backtrace to generate a backtrace of code execution

If you can install extensions on your server, XDebug is very very nice. It also allows you to profile your code to identify any bottle necks. You can also connect it to a remote debugger to do your debugging using a separate application.

like image 168
F21 Avatar answered Sep 21 '22 21:09

F21


You should definitely try psysh.

It's a better shell for php like ipython and supports also interactive debugging as pdb.

like image 37
davekr Avatar answered Sep 20 '22 21:09

davekr