可以将Xdebug与内置的PHP测试服务器一起使用吗? [英] Is it possible to use Xdebug with the built in PHP test server?
问题描述
基本上我的问题说明了一切。
Basically my question says it all.
我希望能够检查脚本变量的状态,设置断点等,而无需安装Nginx,apache或PHP-FPM?
I'd like to be able to inspect the state of the variables of my script, set breakpoints etcétera, without the need to install Nginx, apache or PHP-FPM?
这是否可行,如果没有,我的选择是什么?
Is this doable, if not what would be my options?
推荐答案
还可以从本文设法使用xdebug。
Ok so parting from this article I've managed to use xdebug.
我使用自制软件在Mac OS X 10.10上安装了PHP 5.5
I installed PHP 5.5 on Mac OS X 10.10 using homebrew
-
如果尚未安装PHP,请安装xdebug扩展名;
在我使用的
中$ brew install php55-xdebug
或者如果您已经安装了pecl
和php,请使用$ pecl install xdebug
。
您可以通过执行$ php -m |检查扩展程序是否已安装。 grep xdebug
。
Install PHP if it has not been installed, make sure to install it with the xdebug extension;
in my case I used$ brew install php55-xdebug
or if you havepecl
and php already installed use$ pecl install xdebug
.
You can check if the extension is installed by executing$ php -m | grep xdebug
.
如果将VIM用作 IDE,建议安装 vim病原体插件,然后安装 xdebugger vim插件;
If you use VIM as your "IDE", I'd recommend to install the vim pathogen plugin, then install the xdebugger vim plugin; which I've modified to be pathogen compatible.
$ cd〜/ .vim / bundle&& git clone https://github.com/Triztian/xdebugger.git
接下来,我们必须启用xdebugger扩展;为此,您首先需要找出正在加载哪个 php.ini
文件,可以通过运行 $ php -i |来进行检查。 grep File => /
。找到正确的初始化文件后,必须在末尾添加以下几行:
Next we have to enable the xdebugger extension; to do so first you need to find out which php.ini
file is being loaded, you can check that by running $ php -i | grep "File => /"
. After you've found the correct init file you must add the follwing lines at the end:
xdebug.remote_enable = On
xdebug.remote_autostart = On
如果使用PHP的内置开发服务器,您可以使用 -c
参数指定一个php.ini文件。
If using PHP's built-in development server, you can use the -c
argument to specify a php.ini file.
现在,启动php开发服务器(在我的情况下为 $ php -S localhost:8080 -c /usr/local/etc/php/5.5/php.ini
),然后打开VIM。打开VIM后,按< f5>
,以便xdebugger开始监听连接;在您的浏览器上,导航到 localhost:8080 / index.php
(或任何php脚本),以便在一切都正确设置后触发xdebugger连接。
Now, start the php development server (in my case $ php -S localhost:8080 -c /usr/local/etc/php/5.5/php.ini
) and open VIM. After VIM is open press <f5>
so that the xdebugger starts listening for a connection; on your browser navigate to localhost:8080/index.php
(or any php script) so that it triggers the xdebugger connection if everything has been setup correctly.
您不应该参加调试会话,请查看插件的自述文件以了解其工作原理。
You should no be in a debugging session, look at the plugin's readme to see how it works.
这篇关于可以将Xdebug与内置的PHP测试服务器一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!