php artisan -V)Running php artisan route:cache succeeds:
Route cache cleared!
Routes cached successfully!
But afterwards the following error is thrown when accessing the any page:
ErrorException
Erroneous data format for unserializing 'Symfony\Component\Routing\CompiledRoute'
After running php artisan route:clear the application is accessible again.
Simply running php artisan route:cache and then accessing any route...
I can cache routes just fine. Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to report back and I'll gladly help you out and re-open this issue.
Thanks!
@driesvints Thank you for your time,
I found that there already is a topic on Laracasts and a lot of people have this exact same issue:
I will try to investigate further, to hopefully find what's causing this.
I've recently had a similar problem. I was updating my app from PHP 7.3 to 7.4. The issue was that I ran php artisan route:cache on 7.4 CLI while I still haven't switched FPM from 7.3 to 7.4. After switching FPM to 7.4 everything worked. Make sure that both your PHP CLI and FPM versions match as it looks like that PHP 7.3 cannot unserialize strings which were serialized by PHP 7.4.
I've recently had a similar problem. I was updating my app from PHP 7.3 to 7.4. The issue was that I ran
php artisan route:cacheon 7.4 CLI while I still haven't switched FPM from 7.3 to 7.4. After switching FPM to 7.4 everything worked. Make sure that both your PHP CLI and FPM versions match as it looks like that PHP 7.3 cannot unserialize strings which were serialized by PHP 7.4.
That was indeed the reason. Thank you.
I've recently had a similar problem. I was updating my app from PHP 7.3 to 7.4. The issue was that I ran
php artisan route:cacheon 7.4 CLI while I still haven't switched FPM from 7.3 to 7.4. After switching FPM to 7.4 everything worked. Make sure that both your PHP CLI and FPM versions match as it looks like that PHP 7.3 cannot unserialize strings which were serialized by PHP 7.4.
This solution also worked for me . Thank you!
I've recently had a similar problem. I was updating my app from PHP 7.3 to 7.4. The issue was that I ran
php artisan route:cacheon 7.4 CLI while I still haven't switched FPM from 7.3 to 7.4. After switching FPM to 7.4 everything worked. Make sure that both your PHP CLI and FPM versions match as it looks like that PHP 7.3 cannot unserialize strings which were serialized by PHP 7.4.
If anyone STILL have this issue even though PHP versions match, try restarting the server.
I'm using Laravel Forge, I upgraded to PHP7.4 (through Forge UI) and everything was correct in the config (nginx, php-fpm, php-cli). But the error remained. Then I restarted the server through forge UI and everything works fine now.
Most helpful comment
I've recently had a similar problem. I was updating my app from PHP 7.3 to 7.4. The issue was that I ran
php artisan route:cacheon 7.4 CLI while I still haven't switched FPM from 7.3 to 7.4. After switching FPM to 7.4 everything worked. Make sure that both your PHP CLI and FPM versions match as it looks like that PHP 7.3 cannot unserialize strings which were serialized by PHP 7.4.