Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Class 'LaravelLocalization' not found after composer install in production

It's been 3 days since I'm working on translating my site, so I installed LaravelLocalization:

I did everything working in local, then I pushed it in production and executed:

composer install --no-interaction --no-dev
php artisan clear-compiled
php artisan optimize
composer dump-autoload -o
php artisan route:cache
php artisan config:cache

Now, all the "php artisan commands fail with:"

 [Symfony\Component\Debug\Exception\FatalThrowableError]  
 Fatal error: Class 'LaravelLocalization' not found       

In this case, in the composer install script, it fails in:

php artisan clear-compiled

I tried to run:

php artisan cache:clear
php artisan route:clear

But without any results...

Any ideas??? This is not the first time I get this kind of stuff, but I may say that this it's a pain in the ass :(

EDIT:

In my routes.php,

I deleted this line:

Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localeSessionRedirect', 'localizationRedirect']],

around all my routes, and now composer install works.

But it doesn't solve my issue, because as soon as I put it back, I still get the same error :(

like image 313
Juliatzin Avatar asked Oct 28 '25 17:10

Juliatzin


2 Answers

I resolved it removing the line:

Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localeSessionRedirect', 'localizationRedirect']], 

in my file routes.php

run again

composer install

and finally

php artisan config:clear
php artisan route:clear

What I don't know is why it happened, and if there is a way to prevent it...

like image 147
Juliatzin Avatar answered Oct 31 '25 06:10

Juliatzin


as what the error says, it means that the composer can't locate your package. so be sure to check your config/app.php file be sure to put the package in providers and aliases arrays, respectively.

like image 45
Rolandoz Avatar answered Oct 31 '25 07:10

Rolandoz