php - 带有 Xdebug 的 Laravel 5 总是抛出 "The payload is invalid."

标签 php laravel xdebug

我在 VScode 上配置了 Xdebug 来调试我的 Laravel 应用程序。但是,当我开始调试时,laravel 总是抛出这个错误:Exception has occurred。 Illuminate\Contracts\Encryption\DecryptException:负载无效。

我已经尝试运行 php artisan optimize

这里有人遇到过这个问题吗?我正在使用 Laravel 5.5

附言。我试图调试 Laravel 4 应用程序。它没有任何问题。所以,我认为这可能是 Laravel 5 特有的东西。

最佳答案

默认情况下,Laravel 将加密并随后解密请求中的所有 cookie。

当使用 Xdebug 从浏览器调试您的应用程序时,会设置一个名为“XDEBUG_SESSION”的 cookie。由于此 cookie 未被 Laravel 框架设置,因此未被加密,因此当框架自动检测并尝试解密 cookie 时将抛出错误。

正确的解决方案是将“XDEBUG_SESSION”cookie 添加到 App\Http\Middleware\EncryptCookies 中间件的异常数组中。

/**
 * The names of the cookies that should not be encrypted.
 *
 * @var array
 */
protected $except = [
    'XDEBUG_SESSION'
];

关于php - 带有 Xdebug 的 Laravel 5 总是抛出 "The payload is invalid.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47355311/

相关文章:

windows - Docker xDebug 未连接到 VSCode

php - XDebug 未加载到 PHP(Vista、Apache 模块)中

php - 性能: PHP Error Handling and Regex

php - SQL 中有数值 - 我想减去它

php - Laravel 中 `HtmlString` 有什么用?

laravel - 如何使用 Laravel 在下拉列表中显示数据库中的选定值?

php - 如何使用 xdebug 查找 php 内存泄漏?

php - SQL 注入(inject) - 这(oneliner)安全吗?

php - 关系表 PDO 查看全部

jquery - 让 Laravel 返回 JSON