2016-04-11 03:08
浏览 268


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:"

 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 :(


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 :(

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongsui8162 2016-04-11 04:09

    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...

    打赏 评论
  • ds15812330851 2016-04-11 03:58

    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.

    打赏 评论
  • douda5227 2016-04-11 08:02

    This has been a known issue for a while, but has actually finally been resolved recently. You can read about the issue here.

    Basically, running php artisan loads the entire framework, including the cached files. Since the cached files don't have your service provider, you get the error. This includes running php artisan clear-compiled. So, it is using the cached files in the command that is used to delete the cached files.

    This issue has finally been resolved as of laravel/framework:v5.2.25 and laravel/laravel:v5.2.27, and backported to laravel/framework:v5.1.33 and laravel/laravel:v5.1.33.

    This fix includes a change to the Laravel application (laravel/laravel), in addition to the Laravel Framework (laravel/framework). To implement, you will need to:

    1) Update the scripts section of your composer.json file to match that in the laravel/laravel package. Specifically:

    • remove the pre-update-cmd section
    • in the post-install-cmd section, replace "php artisan clear-compiled" with "Illuminate\\Foundation\\ComposerScripts::postInstall"
    • in the post-update-cmd section, replace "php artisan clear-compiled" with "Illuminate\\Foundation\\ComposerScripts::postUpdate"

    2) Once you have updated your composer.json, run a composer update. If you only want to update the framework, you can run composer update laravel/framework.

    打赏 评论

相关推荐 更多相似问题