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?
我在ruby上有点被宠坏了,我习惯使用惊人的pry设施来应用程序。我将一个应用程序锁定到1个线程,然后让pry在httpd控制台中弹出,然后能够解决很多问题的底部,但是我找不到像PHP中那样的东西。是否有类似或接受的解决方案,这样的PHP用于在执行期间调试和跟踪数据结构等?
6 个解决方案
#1
14
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:
我确切地知道你的意思。转移到PHP后我也错过了Pry。到目前为止,PsySH看起来像PHP最好的REPL,最像Pry。它有反射,因此您可以使用像ls这样的命令来评估变量,常量,类等。它有一个帮助命令,类似于Pry的show-doc,它允许您阅读有关函数或对象属性的文档。您甚至可以查看任何对象的来源,就像Pry的show-source命令一样。还调试:
"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:
“PsySH可以用作交互式调试器,就像JavaScript的调试器语句一样,可以避免无休止的var_dump()和die()迭代。只需将此行放在您想要断点的地方:
\Psy\Shell::debug(get_defined_vars());"
Boris is also another good REPL for PHP that is similar to Pry.
Boris也是PHP的另一个很好的REPL,类似于Pry。
#2
2
Yeah. Called dephpugger
是啊。叫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...
您也可以在终端和调试器中启动服务器。命令类似,n到next,c继续等等......
#3
0
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.
我并不是真正的Ruby和pry,但就我读到的主题而言,pry是一个debugtool。为了调试php,我使用一个名为wamp的本地web服务器和内置的xDebug。结合IDE:Netbeans或Eclipse,您可以在执行php脚本期间查看数据结构/对象。
#4
0
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
我也在寻找一个类似于pry的东西,但这个帮助我实现了类似的东西:http://proger.i-forge.net/Triggering_XDebug_session_from_command_line/ODd
#5
#6
0
PHP works differently from Ruby, it's kind of hard to compare within the context you are asking about.
PHP与Ruby的工作方式不同,在您询问的上下文中很难进行比较。
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).
在运行时检查复杂结构是通过调试在PHP中完成的,这意味着客户端调试端(= PHP IDE)必须能够与运行PHP的服务器调试端通信(这通常通过使用特殊名称启动cookie来完成,例如通过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.
因此,Web服务器上的PHP必须安装特殊的调试模块(如XDebug),当调试客户端说“立即停止”时,Web服务器会在某个断点处暂停执行,从而暴露任何本地,全局,静态等数据结构。
If interested, take a look at available PHP IDEs with support for debugging: What is the best IDE for PHP?
如果有兴趣,请查看支持调试的可用PHP IDE:什么是PHP的最佳IDE?
#1
14
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:
我确切地知道你的意思。转移到PHP后我也错过了Pry。到目前为止,PsySH看起来像PHP最好的REPL,最像Pry。它有反射,因此您可以使用像ls这样的命令来评估变量,常量,类等。它有一个帮助命令,类似于Pry的show-doc,它允许您阅读有关函数或对象属性的文档。您甚至可以查看任何对象的来源,就像Pry的show-source命令一样。还调试:
"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:
“PsySH可以用作交互式调试器,就像JavaScript的调试器语句一样,可以避免无休止的var_dump()和die()迭代。只需将此行放在您想要断点的地方:
\Psy\Shell::debug(get_defined_vars());"
Boris is also another good REPL for PHP that is similar to Pry.
Boris也是PHP的另一个很好的REPL,类似于Pry。
#2
2
Yeah. Called dephpugger
是啊。叫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...
您也可以在终端和调试器中启动服务器。命令类似,n到next,c继续等等......
#3
0
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.
我并不是真正的Ruby和pry,但就我读到的主题而言,pry是一个debugtool。为了调试php,我使用一个名为wamp的本地web服务器和内置的xDebug。结合IDE:Netbeans或Eclipse,您可以在执行php脚本期间查看数据结构/对象。
#4
0
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
我也在寻找一个类似于pry的东西,但这个帮助我实现了类似的东西:http://proger.i-forge.net/Triggering_XDebug_session_from_command_line/ODd
#5
0
I have not worked on Ruby.
我还没有使用过Ruby。
But PHP debugging can be done through
但PHP调试可以通过完成
*)
WAMP server with Firebug and FirePHP
使用Firebug和FirePHP的WAMP服务器
#6
0
PHP works differently from Ruby, it's kind of hard to compare within the context you are asking about.
PHP与Ruby的工作方式不同,在您询问的上下文中很难进行比较。
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).
在运行时检查复杂结构是通过调试在PHP中完成的,这意味着客户端调试端(= PHP IDE)必须能够与运行PHP的服务器调试端通信(这通常通过使用特殊名称启动cookie来完成,例如通过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.
因此,Web服务器上的PHP必须安装特殊的调试模块(如XDebug),当调试客户端说“立即停止”时,Web服务器会在某个断点处暂停执行,从而暴露任何本地,全局,静态等数据结构。
If interested, take a look at available PHP IDEs with support for debugging: What is the best IDE for PHP?
如果有兴趣,请查看支持调试的可用PHP IDE:什么是PHP的最佳IDE?