简体   繁体   English

使用sublimetext 3在ubuntu 16.04的laravel项目中使用xdebug

[英]xdebug in a laravel project in ubuntu 16.04 using sublimetext 3

I'm moreless new with this kind of things, I'm trying to setup xdebug to debug a laravel project I'm developing in my Ubuntu 16.04, I have installed sublime text with the package control and the xdebug client, I installed from apt-get the packages 我最不喜欢这种事情,我正在尝试设置xdebug来调试我在Ubuntu 16.04中开发的laravel项目,我已经使用包控件和xdebug客户端安装了sublime文本,我是从apt安装的-获取包

php (7.0) php-xdebug php-all-dev php-fpm

the laravel project already works with the comand laravel项目已经可以与comand合作

php artisan serve

I saved the sublime text 3 project with the code 我用代码保存了sublime text 3项目

{
    "folders":
    [
        {
            "follow_symlinks": true,
            "path": "."
        }
    ],
    "settings": {
        "xdebug": {
             "url": "http://localhost/",
        }
    }
}

my /etc/php/7.0/fpm/conf.d/20-xdebug.ini is: 我的/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"

I dont know if I need to use the "php artisan" to debug or just with the xdebug plugin in sublime text, nothing apear to work 我不知道我是否需要使用“ php artisan”进行调试,或者仅使用xdebug插件进行出色的文字显示,没有任何效果

any ideas? 有任何想法吗?

thanks for everything 感谢一切

Here is my config for 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

Note the remote_autostart , which made all my debugging work correctly. 注意remote_autostart ,它使我所有的调试都能正常工作。

I don't use sublime, but this config worked correctly in Atom, PhpStorm, VSCode and Netbeans, and I assume it will work virtually for all compatible debugger clients. 我不使用sublime,但是此配置在Atom,PhpStorm,VSCode和Netbeans中均能正常工作,并且我认为它实际上可用于所有兼容的调试器客户端。 Make sure that the port, host and idekey fields are the same in sublime and your config file, that's all. 确保sublime和配置文件中的port,host和idekey字段相同,仅此而已。

The thing is, you have to know how xdebug works. 关键是,您必须知道xdebug的工作方式。 Then you can set it up everywhere easily. 然后,您可以轻松地在任何地方进行设置。

xdebug works but connecting to the remote_host and remote_port you specify in its config. xdebug可以工作,但是连接到您在其配置中指定的remote_hostremote_port That means, when a PHP script is going to be executed, first, if loaded, xdebug tries to connect to that address. 这意味着,当将要执行PHP脚本时,首先,如果加载了xdebug,则xdebug会尝试连接到该地址。 If a compatible debugger is listening on the other side, then connection is made, and the debugger can do its debugging. 如果兼容的调试器在另一端侦听,则建立连接,调试器可以进行调试。 Note that, xdebug, as in sockets terminology, is a client to your server (ide, debugger, ...). 请注意,与套接字术语一样,xdebug是服务器客户端 (例如,调试器,...)。 So your ide must be listening first, before PHP script is executed. 因此,在执行PHP脚本之前,您的想法必须首先侦听。 In sublime, find something like listening for connections . 崇高地寻找诸如聆听人脉的东西。

For debugging if problem is with your ide or xdebug itself, you can use debugclient , a tool that acts as a server for xdebug. 如果您的ide或xdebug本身有问题,则可以使用debugclient ,该工具充当xdebug的服务器。 Just run debugclient and execute a PHP script, with xdebug loaded (which seems you have it). 只需运行debugclient并执行一个装载了xdebug的PHP脚本(看来您已经拥有了)。 If it shows that connection is made, than sublime has a configuration problem. 如果显示已建立连接,则说明sublime存在配置问题。 If not, check xdebug config again, and make sure everything is ok. 如果没有,请再次检查xdebug config,并确保一切正常。

I have seen systems where debugclient is not installed by default. 我已经看到默认情况下未安装debugclient系统。 You can also test with nc -l 9000 or whatever port to test it too. 您也可以使用nc -l 9000或任何端口进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM