문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

I'm not really into Ruby and pry but as far as i have read into the topic pry is a debugtool. For debugging php I use a local webserver called wamp with the built in xDebug. In combination with the IDE : Netbeans or Eclipse you can look into datastructures/objects during execution of your php script.

I'm looking at a pry-like too, but this one helped me to achieve something similar: http://proger.i-forge.net/Triggering_XDebug_session_from_command_line/ODd

I have not worked on Ruby.

But PHP debugging can be done through

*)

WAMP server with Firebug and FirePHP

PHP works differently from Ruby, it's kind of hard to compare within the context you are asking about.

Inspecting complex structures within runtime is done in PHP via debugging, which means that client debug side (= PHP IDE) must be able to communicate with server debug side running PHP (this is usually done by initiating cookie with special name, e.g. via URL DBGSESSID=123&dbgParam1=123).

So PHP on the web server must have special debugging module installed (like XDebug) and when debugging-client says "stop now", then web server pauses execution at certain breakpoint exposing any local, global, static etc.. data structures.

If interested, take a look at available PHP IDEs with support for debugging: What is the best IDE for PHP?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top