【问题标题】:How to setup XDebug with VSCode on Ubuntu on a Laravel project?如何在 Laravel 项目的 Ubuntu 上使用 VSCode 设置 XDebug?
【发布时间】:2023-03-30 13:49:02
【问题描述】:

我正在做一个简单的 laravel 项目,我有一些代码要调试,但我无法在 VSCode 上进行调试。

我在Ubuntu 19.10。我正在使用VSCode Insiders 和带有 XDebug 扩展的 Firefox。我按照xdebug.org/wizard 上的指南进行操作,但没有成功。

这是我的 php.ini 中的 xdebug 配置

[xdebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.idekey = VSCODE
xdebug.remote_port=9000

这是我的 launch.json

"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000

还有我的 php -v

$ php -v
PHP 7.3.11-0ubuntu0.19.10.1 (cli) (built: Oct 24 2019 11:38:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11-0ubuntu0.19.10.1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.8.0, Copyright (c) 2002-2019, by Derick Rethans

我希望能够调试我的laravel 代码,但是当我在代码中设置断点时,它不起作用。不过,我能够捕获常规 php 文件中的断点。

【问题讨论】:

    标签: php laravel visual-studio-code xdebug


    【解决方案1】:

    我想通了。我正在使用命令

    php artisan serv
    

    并通过127.0.0.1:8000 访问我的服务器,这导致了问题。

    需要将项目放到/var/www/html/文件夹中,然后通过127.0.0.1/yourApp/public/访问

    您可能需要将文件 storagebootstrap/cache 添加到网络服务器用户:How to fix Error: laravel.log could not be opened?

    【讨论】:

      猜你喜欢
      • 2021-07-03
      • 1970-01-01
      • 2021-03-14
      • 2020-10-24
      • 1970-01-01
      • 1970-01-01
      • 2015-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多