Skip to content

Route caching doesn't work in Laravel 11 #927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vincentsch opened this issue Jan 4, 2025 · 5 comments
Open

Route caching doesn't work in Laravel 11 #927

vincentsch opened this issue Jan 4, 2025 · 5 comments
Labels

Comments

@vincentsch
Copy link

vincentsch commented Jan 4, 2025

Describe the bug
Route caching doesn't work in Laravel 11. The package's caching documentation relies on RouteServiceProvider which has been removed in Laravel 11.

To Reproduce

  1. Create new Laravel 11 project
  2. Install mcamara/laravel-localization
  3. Follow caching setup guide at https://github.com/mcamara/laravel-localization/blob/master/CACHING.md
  4. Get error when running artisan route:trans:cache because RouteServiceProvider doesn't exist
  5. Without those modifications get 404 errors on localized routes after caching routes

Expected behavior
Route caching should work with Laravel 11's new routing system

More info:

  • Laravel Version: 11.x
  • Laravel-localization Version: 1.8.2
  • Middleware: localize, localizationRedirect, localeCookieRedirect, localeViewPath
  • Config:
'supportedLocales' => [
    'en' => ['name' => 'English', 'script' => 'Latn', 'native' => 'English', 'regional' => 'en_GB'],
    'de' => ['name' => 'German', 'script' => 'Latn', 'native' => 'Deutsch', 'regional' => 'de_DE']
],
'useAcceptLanguageHeader' => false,
'hideDefaultLocaleInURL' => true

Additional context
Current caching documentation at https://github.com/mcamara/laravel-localization/blob/master/CACHING.md is incompatible with Laravel 11.

@iwasherefirst2
Copy link
Collaborator

Thank you for reporting this bug. Unfortunately, I’m not aware of a simple workaround for version 11 at the moment. However, we are actively working on version 3 of this package, which will eliminate the need for custom caching and fully leverage Laravel’s built-in cache. This update will resolve the issue once it’s ready.

@jbelien
Copy link

jbelien commented Feb 4, 2025

@iwasherefirst2 Excellent news! 👍

Laravel 10 has reached End of Life today, when can we expect version 3 of Laravel Localization ?

And would version 3 also allow the use of Octane (see #780 & #828) ?

Thanks & Good luck for version 3! 💪

@szwss
Copy link

szwss commented Feb 11, 2025

Hopefully version 3 will support older versions,
such as laravel8, but due to historical reasons,
I haven't been able to upgrade to laravel10 and 11 for the time being

@iwasherefirst2
Copy link
Collaborator

@jbelien The translated routes are my biggest concern. I need to find a good solution that minimizes breaking changes. I expect version 3.x to be released within the next 2–3 months at the latest.

I believe our changes will make it compatible with Octane, but that's not a goal for this release. It would be great if someone could test it once 3.x is ready and confirm

@szwss I’d like to ensure compatibility with Laravel 9, but I can't make any guarantees at this point.

@a-smily
Copy link

a-smily commented Apr 2, 2025

I can't get route caching to work with Laravel 12 either - are there any plans for updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants