Dye*_*ery 11 php xdebug laravel
我在VScode上配置Xdebug来调试我的laravel应用程序.但是,当我开始调试时,laravel总是抛出这个错误:Exception has occurred. Illuminate\Contracts\Encryption\DecryptException: The payload is invalid.
我已经试过了php artisan optimize.
这里有人已经遇到过这个问题吗 我正在使用Laravel 5.5
PS.我试图调试Laravel 4应用程序.它没有任何问题.所以,我认为这可能是Laravel 5特有的.
Jon*_*han 28
默认情况下,Laravel将对请求中的所有cookie进行加密,并随后解密.
使用Xdebug从浏览器调试应用程序时,会设置一个名为"XDEBUG_SESSION"的cookie.由于Laravel框架未设置此cookie,因此未加密,因此当框架自动检测并尝试解密cookie时,将引发错误.
正确的解决方案是将"XDEBUG_SESSION"cookie添加到App\Http\Middleware\EncryptCookies中间件中的exceptions数组中.
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
'XDEBUG_SESSION'
];
Run Code Online (Sandbox Code Playgroud)
如果答案不起作用,请尝试将其添加到launch.json中
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9001,
"ignore": [
"**/vendor/**/*.php"
]
},
Run Code Online (Sandbox Code Playgroud)
更多信息:https : //stackoverflow.com/a/49795318/1998033