Skip to content
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

got 404 not found after using php artisan route:trans:cache #904

Closed
mgaber2024 opened this issue May 28, 2024 · 2 comments
Closed

got 404 not found after using php artisan route:trans:cache #904

mgaber2024 opened this issue May 28, 2024 · 2 comments

Comments

@mgaber2024
Copy link

Describe the bug
I got 404 after I used php artisan route:trans:cache command and added
use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes; in route service provider as described in the docs

Expected behavior
I should can access the app routes normally

More info:

  • Version of Laravel 10.48.11
  • Version of the Laravel-localization package 2.0.1
  • Which middleware is used in Route::groups
    'localeSessionRedirect',
    'localizationRedirect',
    'localeViewPath'
  • Copy of the config file
  'supportedLocales' => [
 'en'          => ['name' => 'English',                'script' => 'Latn', 'native' => 'English', 'regional' => 'en_GB'],
    'ar'          => ['name' => 'Arabic',                 'script' => 'Arab', 'native' => 'العربية', 'regional' => 'ar_AE'],
]

 'useAcceptLanguageHeader' => true,

  'hideDefaultLocaleInURL' => false,

`
@tringuyenduc2903
Copy link

Two ways to solve this problem
#899 (comment)

class AppServiceProvider extends ServiceProvider
{
    use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;

    public function boot(): void
    {
        RouteServiceProvider::loadCachedRoutesUsing(fn() => $this->loadCachedRoutes());
        ...
    }

(or)

https://github.com/mcamara/laravel-localization?tab=readme-ov-file#caching-routes

<?php
class RouteServiceProvider extends ServiceProvider
{
    use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;

@MilanUnjiya4149
Copy link

RouteServiceProvider::loadCachedRoutesUsing(fn() => $this->loadCachedRoutes());

This solution is working.

@tringuyenduc2903 Thank You ☺

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

No branches or pull requests

4 participants