wsl for window环境通过vscode工具debug php的laravel框架项目

背景

php:7.2
宿主机环境:wsl for window
开发工具:vscode

步骤1:通过phpstudy配置php、xdebug

命令窗口执行
wget -O install.sh https://notdocker.xp.cn/install.sh && sudo bash install.sh
执行结束,自动给出地址,账户密码等信息,安装下图信息安装php、给安装的php配置xdebug

步骤2:通过phpstudy配置php.ini的xdebug环境

xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000

步骤3:vscode配置环境

先下载php debug插件

配置vscode 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": 9000,
        "stopOnEntry":true,
        "pathMappings": {
            "你要debug的php laravel项目根目录\":"你要debug的php laravel项目根目录\",
        },
        "log": true
    }
]

}`
在.env中添加两个代码
XDEBUG_MODE=debug
XDEBUG_SESSION=vscode

步骤4:开始debug

先点击debug

再脚本启动:
php artisan serve --env production
此时debug效果就有了

posted @ 2024-01-25 17:07  王吉平  阅读(94)  评论(1编辑  收藏  举报