Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a `pry` equivalent exist for php?

I'm a bit spoiled on ruby and am used to using the amazing pry facilities for apps. I'll lock an app down to 1 thread and then let pry pop open in the httpd console and then be able to get to the bottom of a lot of issues, however I am not finding anything quite like this available in PHP. Is there a similar or accepted solution that works like this for PHP for debugging and tracing out data structures, etc. during execution?

like image 549
ylluminate Avatar asked Apr 25 '13 19:04

ylluminate


2 Answers

I know exactly what you mean. I missed Pry after moving to PHP as well. So far PsySH looks like the best REPL for PHP that is the most like Pry. It has reflection, so you can use commands like ls to evaluate the variables, constants, classes, etc. It has a help command, similar to Pry's show-doc that allows you to read documentation on functions or object properties. You can even view the source of any object, just like Pry's show-source command. Also debugging:

"PsySH can be used as an interactive debugger, much like JavaScript's debugger statement, saving you from endless var_dump() and die() iterations. Just drop this line in where you'd like to have a breakpoint:

\Psy\Shell::debug(get_defined_vars());"

Boris is also another good REPL for PHP that is similar to Pry.

like image 200
Adam Avatar answered Oct 05 '22 11:10

Adam


Yeah. Called dephpugger

https://github.com/tacnoman/dephpugger

You start the server in terminal and debugger too. The commands are similar, n to next, c to continue, etc...

like image 25
Renato Cassino Avatar answered Oct 05 '22 11:10

Renato Cassino