mcamara / laravel-localization

Easy localization for Laravel
MIT License
3.38k stars 515 forks source link

Route caching gives Error 404 #749

Closed marijoo closed 4 years ago

marijoo commented 4 years ago

@iwasherefirst2 I created a minimal setup on a fresh Laravel 7 installation and put it in a repo. You can find the commit here: https://github.com/marijoo/laravel-localization-route-cache/commit/90924fba385ab8e5074ab95a3a1c96f6d6863f36

As you can see this is a minimal setup but the problem occurs as described above:

This happens with php artisan optimize, php artisan route:cache as well as with php artisan route:trans:cache. After clearing the cache with php artisan cache:clear routes work again.

Can you reopen this issue, please? If I can further help, please don't hesitate.

Originally posted by @marijoo in https://github.com/mcamara/laravel-localization/issues/736#issuecomment-691221984

reganjohnson commented 4 years ago

Having the same issues.

iwasherefirst2 commented 4 years ago

@marijoo thank you for providing an example. Sorry for taking so long, I had not PHP 7.3 installed and it took me a moment to setup docker.

Anyway, I just noticed that you did not use the LoadsTranslatedCachedRoutes trait in your RouteServiceProvider as explained here. This should definitely be pointed out in the docs. I will create a MR for it.

Btw: route:cache will break the usage of this package. And to clear route cache one should use route:trans:clear

marijoo commented 4 years ago

Whoa, I did not notice anything like this at all. I will try this in the coming week and respond back. Thank you! 🙌🏻

hubtraum commented 4 years ago

Whoa, I did not notice anything like this at all. I will try this in the coming week and respond back. Thank you! 🙌🏻

Had the same issue / did not notice the trait for the RouteServiceProvider. Added the mentioned LoadsTranslatedCachedRoutes trait and can confirm this works as expected.

marijoo commented 4 years ago

Thank you, I can now confirm this works.