-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
Caching routes #308
Comments
No it's not possible in its current implementation. Route::group([
'prefix' => LaravelLocalization::setLocale(),
'middleware' => [
'localeSessionRedirect',
'localizationRedirect',
],
], function () {
...
}
]; So when a HTTP request arrives, If you call In order to achieve this we would need to generate every route combination foreach language. foreach(LaravelLocalization::getLanguageList() as $language) {
Route::group([
'prefix' => $language,
'middleware' => [
'localeSessionRedirect',
'localizationRedirect',
],
], function () {
...
}
];
} And obviously such an implementation would require a major version update. |
I tried with no luck before your message... the thing is I am translating the routes as well using the |
@mgarciadelojo See this old issue #201 |
This is a must. I'm having the same problem. |
I found a fix!!!! routes.php
Controller.php
vendor\laravel\framework\src\Illuminate\Foundation\helpers.php
Afterward php artisan route:cache works like a charm! ENJOY! |
Hi. You should not change core files. See the solution in #201. |
You can override 'route' function declaration so it gets loaded before the core one. Should be better this way. |
If anyone's interested, I wrote a simple solution that works fine for our company's projects: https://github.com/czim/laravel-localization-route-cache This allows you to use Additionally, you can list the routes for a specific locale with It's not pretty, a bit of a hack-job (using a Your mileage may vary, but I very much welcome feedback & suggestions. |
@czim Tried your solution but found a problem. Cheers |
Can you make an issue out of it in my repo, with some snippets from the routes file, so I know how you've set it up? I'll try to reproduce and fix it then. |
@czim Thank you. Sure I will. Let me get some time to perform another test with a fresh project and then I create the issue if needed. Cheers |
The problem mentioned by rsdev000 has been fixed in a new version, thanks to MrVokia. |
@mcamara Hey! You should merge this package https://github.com/czim/laravel-localization-route-cache What do you think about it? |
I've added a section in the README.md redirecting the user to czim's package. Thanks for your help! |
Hi guys,
Is there any plan for caching routes? If not, I offer my help in order to implement it. I noticed that response times are a lot higher when routes are not cached.
Best regards,
The text was updated successfully, but these errors were encountered: