I configured Xdebug on VScode to debug my laravel application. But, when I start to debug, laravel always throws this error: Exception has occurred. Illuminate\Contracts\Encryption\DecryptException: The payload is invalid.
I already tried to run php artisan optimize
.
Anyone here already faced this issue? I'm using Laravel 5.5
Ps. I tried to debug a Laravel 4 application. It worked without any issues. So, I think it may be something specific for Laravel 5.
By default Laravel will encrypt, and subsequently also decrypt, all cookies on a request.
When using Xdebug to debug your application from a browser, a cookie called "XDEBUG_SESSION" is set. As this cookie was not set, and thus not encrypted, by the Laravel framework, an error will be thrown when the framework automatically detects and tries to decrypt the cookie.
The correct solution is to just add the "XDEBUG_SESSION" cookie to the exceptions array in the App\Http\Middleware\EncryptCookies
middleware.
/** * The names of the cookies that should not be encrypted. * * @var array */ protected $except = [ 'XDEBUG_SESSION' ];
If the answer doesn't work, try adding this into launch.json
{ "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9001, "ignore": [ "**/vendor/**/*.php" ] },
More info: https://stackoverflow.com/a/49795318/1998033
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With