dsndm82062
dsndm82062
2016-08-05 04:10

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 duandong1963 5年前

    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.

    点赞 评论 复制链接分享