laravel 项目中的 xdebug ubuntu 16.04 使用 sublime text 3
xdebug in a laravel project in ubuntu 16.04 using sublimetext 3
我对这类事情比较陌生,我正在尝试设置 xdebug 来调试我在 Ubuntu 16.04 中开发的 laravel 项目,我已经安装了 sublime text使用包控制和 xdebug 客户端,我从 apt-get 安装包
php (7.0) php-xdebug php-all-dev php-fpm
laravel 项目已经可以使用命令
php artisan serve
我用代码保存了sublime text 3项目
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings": {
"xdebug": {
"url": "http://localhost/",
}
}
}
我的/etc/php/7.0/fpm/conf.d/20-xdebug.ini是:
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 8000
xdebug.remote_log="/var/log/xdebug/xdebug.log"
我不知道我是否需要使用 "php artisan" 进行调试或仅使用 sublime text 中的 xdebug 插件,似乎没有任何效果
有什么想法吗?
感谢一切
这是我的 xdebug 配置:
zend_extension=/usr/lib/php/modules/xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.remote_autostart=1
请注意 remote_autostart
,它使我的所有调试工作正常。
我不使用 sublime,但此配置在 Atom、PhpStorm、VSCode 和 Netbeans 中工作正常,我认为它几乎适用于所有兼容的调试器客户端。确保端口、主机和 idekey 字段在 sublime 和你的配置文件中是相同的,仅此而已。
问题是,您必须了解 xdebug 的工作原理。然后你就可以轻松地在任何地方设置它了。
xdebug 工作但连接到您在其配置中指定的 remote_host
和 remote_port
。这意味着,当要执行 PHP 脚本时,首先,如果已加载,xdebug 会尝试连接到该地址。如果兼容的调试器正在侦听其他 side,则建立连接,并且调试器可以进行调试。请注意,在套接字术语中,xdebug 是 客户端 到 服务器 (ide、调试器等)。因此,在执行 PHP 脚本之前,您的 ide 必须先监听。在 sublime 中,找到类似 listening for connections.
的东西
如果问题出在您的 ide 或 xdebug 本身,您可以使用 debugclient
作为 xdebug 服务器的工具进行调试。只需 运行 debugclient
并执行一个 PHP 脚本,并加载 xdebug(看起来你有)。如果显示已建立连接,则说明 sublime 存在配置问题。如果不行,再次检查xdebug配置,确保一切正常。
我见过默认情况下未安装 debugclient
的系统。您也可以使用 nc -l 9000
或任何端口进行测试。
我对这类事情比较陌生,我正在尝试设置 xdebug 来调试我在 Ubuntu 16.04 中开发的 laravel 项目,我已经安装了 sublime text使用包控制和 xdebug 客户端,我从 apt-get 安装包
php (7.0) php-xdebug php-all-dev php-fpm
laravel 项目已经可以使用命令
php artisan serve
我用代码保存了sublime text 3项目
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings": {
"xdebug": {
"url": "http://localhost/",
}
}
}
我的/etc/php/7.0/fpm/conf.d/20-xdebug.ini是:
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 8000
xdebug.remote_log="/var/log/xdebug/xdebug.log"
我不知道我是否需要使用 "php artisan" 进行调试或仅使用 sublime text 中的 xdebug 插件,似乎没有任何效果
有什么想法吗?
感谢一切
这是我的 xdebug 配置:
zend_extension=/usr/lib/php/modules/xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.remote_autostart=1
请注意 remote_autostart
,它使我的所有调试工作正常。
我不使用 sublime,但此配置在 Atom、PhpStorm、VSCode 和 Netbeans 中工作正常,我认为它几乎适用于所有兼容的调试器客户端。确保端口、主机和 idekey 字段在 sublime 和你的配置文件中是相同的,仅此而已。
问题是,您必须了解 xdebug 的工作原理。然后你就可以轻松地在任何地方设置它了。
xdebug 工作但连接到您在其配置中指定的 remote_host
和 remote_port
。这意味着,当要执行 PHP 脚本时,首先,如果已加载,xdebug 会尝试连接到该地址。如果兼容的调试器正在侦听其他 side,则建立连接,并且调试器可以进行调试。请注意,在套接字术语中,xdebug 是 客户端 到 服务器 (ide、调试器等)。因此,在执行 PHP 脚本之前,您的 ide 必须先监听。在 sublime 中,找到类似 listening for connections.
如果问题出在您的 ide 或 xdebug 本身,您可以使用 debugclient
作为 xdebug 服务器的工具进行调试。只需 运行 debugclient
并执行一个 PHP 脚本,并加载 xdebug(看起来你有)。如果显示已建立连接,则说明 sublime 存在配置问题。如果不行,再次检查xdebug配置,确保一切正常。
我见过默认情况下未安装 debugclient
的系统。您也可以使用 nc -l 9000
或任何端口进行测试。