Nate
Nate

Reputation: 427

Laravel artisan route:cache causes Erroneous data Exception

Running the command: php artisan route:cache produces the following execption:

Erroneous data format for unserializing 'Symfony\Component\Routing\CompiledRoute'

Running: php artisan route:clear fixes it

I'd like to know how I can fix this so I can cache my routes.

Upvotes: 17

Views: 10464

Answers (5)

n.y
n.y

Reputation: 3490

For me, this error was solved by deleting the following path files:

\bootstrap\cache

Upvotes: 11

Nate
Nate

Reputation: 427

After a bunch of figuring things out. I found that Apache2 was still using an older version of PHP even though the CLI version was up to date.

After uninstalling all older versions of php and reconfiguring Apache2 to use the latest version fixed this issue.

Upvotes: 3

Subtain Ishfaq
Subtain Ishfaq

Reputation: 841

I hope you are using same php version for CLI and also for the project . Also PHP 7.4 routing cache doesn't work with php 7.3 .

Upvotes: 6

Mykola
Mykola

Reputation: 24

When trying to update Laravel, the same problem arose. The only way that helped me was to downgrade the version of symfony/routing to v4.2.0 (I had v 4.4.3)

composer require symfony/routing:v4.2.0

Upvotes: 0

Vishnu Damwala
Vishnu Damwala

Reputation: 151

This worked for me

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

Upvotes: 12

Related Questions