我正试图在本地主机上调试我的CodeIgniter应用程序。我已经设置了up DB连接,并且可以从浏览器访问服务:
URL: http://localhost/api/are_you_alive
Resp: Yes我按照PHP调试和这里的建议安装了REST,但仍然无法调试REST。
我正在尝试调试/app/Controllers/MyController.php下控制器中的一个方法。
public function index(){
echo "Hi";
}由于框架必须在到达默认控制器之前加载所有配置,所以我已经在/public/index.php上启动了调试器,否则将得到以下错误:
PHP Fatal error: Uncaught Error: Class 'App\Controllers\BaseApi' not found in /var/www/html/my_project/app/Controllers/Api.php:5如果我在没有断点的情况下点击"run“,一切都很顺利。不出所料。但是,当我在任何地方设置断点时,调试器进入一个“无限”循环,它永远不会到达我的断点,也不会停止。
谢谢
更新
我的launch.json文件是:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}如果我在编辑器上打开我感兴趣的控制器进行调试,我会得到:
PHP Fatal error: Uncaught Error: Class 'App\Controllers\BaseApi' not found in /var/www/html/bases/back/app/Controllers/Api.php:5
Stack trace:
#0 {main}
thrown in /var/www/html/bases/back/app/Controllers/Api.php on line 5发布于 2022-02-03 11:11:18
检查你的launch.json是否合适。看看我的兰奇JSON。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug 2 (Legacy)",
"type": "php",
"request": "launch",
"port": 9000
},
]
}还需要检查要调试的视图的autoloads.Open,然后在vs代码中启动调试器,并执行触发断点的操作。
https://stackoverflow.com/questions/70954495
复制相似问题