0

I just installed Mcamara\LaravelLocalization following the documentation but I get an error Call to undefined method Mcamara\LaravelLocalization\Facades\LaravelLocalization::setLocale()

The error comes from the web.php routes file of my package. If I use the same code in my main routes file it works perfect. All other routes of my package work, only those I want to localize don't.

Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['web', 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath']], function() {
    Route::get('/{page}', 'FrontPagesController@index');
});

I found on stackoverflow that this could be because locale in config/app.php is not set but in my case it is set to en.

Can someone help me?

  • go under `app/config.php` and check if locale is set, `'locale' => 'en'` – yoeunes Apr 24 '18 at 15:34
  • it's `config/app.php` and it is set to en, that was the first thing I checked. – Wim Van Dooren Apr 24 '18 at 15:55
  • This can mean that your library isnt loaded, have you added class path? and if you have done it, then try composer dumpautoload – noobie-php Apr 24 '18 at 16:22
  • I did. dup-autoload gives me this error `In Facade.php line 221: Call to undefined method Mcamara\LaravelLocalization\Facades\LaravelLocalization::setLocale() Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1` – Wim Van Dooren Apr 24 '18 at 16:28

1 Answers1

0

I faced this problem and I just run php artisan config:cache in the terminal and I restarted my editor VS Code