将Laravel 5.1升级到5.2时出现致命错误

2022-08-30 09:52:34

我正在按照从5.1到5.2的官方升级指南进行操作。第一小节 说:

如果您要安装 Laravel 5.2 的测试版,请添加到您的 composer.json 文件中。"minimum-stability": "beta"

更新 composer.json 文件以指向 。laravel/framework 5.2.*

将 和 添加到 composer.json 文件的 require-dev 部分。symfony/dom-crawler ~3.0symfony/css-selector ~3.0

现在,在我引入上述更改并运行后,我得到以下错误:composer update

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

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

[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

更新完成后会引发错误,并且会发生“生成自动加载文件”。

可能出了什么问题?

它看起来不像是自定义包问题,而是核心问题。我是否应该继续使用升级指南,并在调整所有内容以适应新的框架版本后运行?composer update

更新

之后运行不会引发上述错误。不过,仍然令人困惑。composer dump-autoload


答案 1

没有了。Illuminate\Routing\ControllerServiceProvider

如果我是你,我会将我的应用程序项目与进行比较,例如,如果你看一下,你会看到Laravel 5.2的默认提供程序:https://github.com/laravel/laravel/commits/develophttps://github.com/laravel/laravel/blob/develop/config/app.php

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,

答案 2

从配置/应用中删除这两个服务提供商.php

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

推荐