Fatal error while upgrading Laravel 5.1 to 5.2

2019-02-05 10:40发布

I'm following the official upgrade guide from 5.1 to 5.2. First sub-section says:

If you are installing a beta release of Laravel 5.2, add "minimum-stability": "beta" to your composer.json file.

Update your composer.json file to point to laravel/framework 5.2.*.

Add symfony/dom-crawler ~3.0 and symfony/css-selector ~3.0 to the require-dev section of your composer.json file.

Now, after I introduce the above changes and run composer update, I get the following error(s):

PHP Fatal error:  Class 'Illuminate\Routing\ControllerServiceProvider' not found 
in /home/vagrant/Code/myproject/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

and

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Illuminate\Routing\ControllerServiceProvider' not found

and

[RuntimeException]
Error Output: PHP Fatal error:  Class 'Illuminate\Routing\ControllerServiceProvider' not found in /home/vagrant/Code/myproject/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

The errors are thrown after the update is done, and "Generating autoload files" takes place.

What might be wrong?

It does not look like a custom package issue, but a core one. Should I continue with the upgrade guide and run composer update AFTER all has been adjusted to suit the new framework version?

UPDATE

Running composer dump-autoload afterwards doesn't throw the errors described above. Still confusing, though.

6条回答
一夜七次
2楼-- · 2019-02-05 10:51

In updating from 5.1 to 5.2 on existing projects, we found that running composer update before and after the removing the lines for the providers

Illuminate\Routing\ControllerServiceProvider::class Illuminate\Foundation\Providers\ArtisanServiceProvider::class

was a necessary sequence to getting the laravel update to complete.

Running before would allow laravel to download and update the current framework library dependencies and then running after the removal (composer was able to complete without issue)

We also found that any value in the .env file cannot have spaces and must be surrounded with quotes to work.

查看更多
Animai°情兽
3楼-- · 2019-02-05 10:51

I found the solution here:

https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0

Service Providers

The Illuminate\Foundation\Providers\ArtisanServiceProvider should be removed from your service provider list in your app.php configuration file.

The Illuminate\Routing\ControllerServiceProvider should be removed from your service provider list in your app.php configuration file.

查看更多
霸刀☆藐视天下
4楼-- · 2019-02-05 10:52

Remove packages.php and config.php from the bootstrap cache folder after run composer dump-autoload

查看更多
Emotional °昔
5楼-- · 2019-02-05 11:02

Remove the two service providers from config/app.php

Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
 Illuminate\Routing\ControllerServiceProvider::class,
查看更多
手持菜刀,她持情操
6楼-- · 2019-02-05 11:04

Updating the app.php file under config/ solved one problem but with the introduction of the bootstrap/cache folder you will probably continue running into the same error.

I ran the composer update Before removing the cached file so I kept hitting the same error. Make sure that you delete the bootstrap/cache/services.php file first.

There might be a artisan command for this but I totally missed this step in the documentation.

查看更多
Root(大扎)
7楼-- · 2019-02-05 11:11

There is no Illuminate\Routing\ControllerServiceProvider any more.

If I were you, I would compare my app project to https://github.com/laravel/laravel/commits/develop, if you for example look at https://github.com/laravel/laravel/blob/develop/config/app.php you will see default providers for Laravel 5.2:

Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
 * Application Service Providers...
 */
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
查看更多
登录 后发表回答