在mac上调试php? [英] debugging php on mac?
问题描述
想知道在本地机器上调试PHP的最佳方式是什么?我在Mac OS 10.5上使用MAMP
谢谢,
Patrick
使用 xdebug 是一个好的开始。下载软件包,并按照 INSTALL
文件中的说明进行操作。这很容易完成之后,将以下行添加到 php.ini
文件中:
;; [xdebug]
zend_extension =/ Path / to / your / module / xdebug.so
xdebug.file_link_format =txmt:// open?url = file://% f& line =%1
xdebug.var_display_max_depth = 20
不要忘记
大多数调试可以使用简单的 die(var_dump($ some_variable))
完成。这不是很复杂,但是使用xdebug安装,vardump的输出在浏览器中看起来相当不错。在大多数情况下,这是足够的。
如果需要更多的控制,可以添加一个 xdebug_break();
语句,并将以下行添加到您的 php.ini
:
xdebug.remote_enable = 1
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
再次,不要忘了重新启动Apache。
现在,使用像 MacGDBp (或Eclipse + PDT,如果你必须),你会得到一个经典的调试器。你可以通过你的节目。
玩得开心!
was wondering what was the best way to debug PHP on my local machine. I use MAMP on mac os 10.5
thanks, Patrick
Using xdebug is a good start. Download the package and follow the instructions in the INSTALL
file. It's fairly easy. Once this is done, add the following lines to your php.ini
file:
;;[xdebug]
zend_extension="/Path/to/your/module/xdebug.so"
xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
xdebug.var_display_max_depth = 20
Don't forget to restart Apache after this.
Most debugging can be done using a simple die(var_dump($some_variable))
. It's not very sophisticated, but with xdebug installed, the output of a vardump looks pretty good in a browser. In most of the cases this is enough.
If you need more control, you can add an xdebug_break();
statement in your code and add the following lines to your php.ini
:
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
Again, don't forget to restart Apache.
Now, using a tool like MacGDBp (or Eclipse+PDT if you must), you get a classic debugger. You can step though your program.
Have fun!
这篇关于在mac上调试php?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!