无法在Laravel项目中使用Visual Code进行调试

van*_*loc 6 php debugging laravel visual-studio-code

我在VSCode上用PHP调试配置成功.

我的问题是当我运行项目时,它总是在函数中出错:

protected function getJsonPayload($payload)
{
    $payload = json_decode(base64_decode($payload), true);

    // If the payload is not valid JSON or does not have the proper keys set we will
    // assume it is invalid and bail out of the routine since we will not be able
    // to decrypt the given value. We'll also check the MAC for this encryption.
    if (! $this->validPayload($payload)) {
        throw new DecryptException('The payload is invalid.');
    }

    if (! $this->validMac($payload)) {
        throw new DecryptException('The MAC is invalid.');
    }

    return $payload;
}
Run Code Online (Sandbox Code Playgroud)

... 从文件: /srv/http/laravelproject/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php

我无法调试我设置的断点.

Gif屏幕记录:http://i.imgur.com/6pNkoHe.gif

小智 10

在Laravel中使用Docker与VsCode和xDebug时遇到同样的问题.

对于任何对不同方法感兴趣的人(因为Laravel 5.6 optimize不再有命令)

只需将该ignore部分添加到您的launch.json配置即可.

{
   "name": "Listen for XDebug",
   "type": "php",
   "request": "launch",
   "port": 9000,
   "pathMappings": {
       "/var/www/html": "${workspaceRoot}",
    },
    // add this
    "ignore": [
        "**/vendor/**/*.php"
    ]
},
Run Code Online (Sandbox Code Playgroud)

为我解决了这个问题.

Docker Github Repo得到了这个


Rob*_*itt 5

你的问题似乎是一个相关的帖子来,它提供了一个很好的答案.另外,我的问题是你为什么使用DecryptException?Laravel bcrypt(用于密码散列)和csrf tokens(表单数据加密)更容易使用.

对于那些寻求快速回答而不阅读评论的人:

在Eloquent中运行以下命令:

php artisan optimize- > php artisan cache:clear- >composer dump-autoload