dsndm82062 2016-08-05 04:10
浏览 52
已采纳

xdebug在ubuntu 16.04的laravel项目中使用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

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

the laravel project already works with the comand

php artisan serve

I saved the sublime text 3 project with the code

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

my /etc/php/7.0/fpm/conf.d/20-xdebug.ini is:

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

any ideas?

thanks for everything

  • 写回答

1条回答 默认 最新

  • duandong1963 2016-08-05 13:48
    关注

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

    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. Make sure that the port, host and idekey fields are the same in sublime and your config file, that's all.

    The thing is, you have to know how xdebug works. Then you can set it up everywhere easily.

    xdebug works but connecting to the remote_host and remote_port you specify in its config. That means, when a PHP script is going to be executed, first, if loaded, xdebug tries to connect to that address. 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, ...). So your ide must be listening first, before PHP script is executed. 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. Just run debugclient and execute a PHP script, with xdebug loaded (which seems you have it). If it shows that connection is made, than sublime has a configuration problem. If not, check xdebug config again, and make sure everything is ok.

    I have seen systems where debugclient is not installed by default. You can also test with nc -l 9000 or whatever port to test it too.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条