php 将 Laravel 5.1 升级到 5.2 时出现致命错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34395129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fatal error while upgrading Laravel 5.1 to 5.2
提问by lesssugar
I'm following the official upgrade guidefrom 5.1 to 5.2. First sub-section says:
我正在遵循从 5.1 到 5.2的官方升级指南。第一个小节说:
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
andsymfony/css-selector ~3.0
to the require-dev section of your composer.json file.
如果您正在安装 Laravel 5.2 的 beta 版本,请添加
"minimum-stability": "beta"
到您的 composer.json 文件中。更新您的 composer.json 文件以指向
laravel/framework 5.2.*
.将
symfony/dom-crawler ~3.0
和添加symfony/css-selector ~3.0
到 composer.json 文件的 require-dev 部分。
Now, after I introduce the above changes and run composer update
, I get the following error(s):
现在,在我介绍上述更改并运行后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
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 afterthe 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?
它看起来不像是自定义包问题,而是核心问题。我是否应该继续升级指南并在composer update
所有已调整以适应新框架版本后运行?
UPDATE
更新
Running composer dump-autoload
afterwards doesn't throw the errorsdescribed above. Still confusing, though.
composer dump-autoload
之后运行不会抛出上述错误。尽管如此,仍然令人困惑。
回答by Marcin Nabia?ek
There is no Illuminate\Routing\ControllerServiceProvider
any more.
没有Illuminate\Routing\ControllerServiceProvider
了。
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:
如果我是你,我会将我的应用程序项目与 进行比较https://github.com/laravel/laravel/commits/develop
,例如,如果您https://github.com/laravel/laravel/blob/develop/config/app.php
查看 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,
回答by iowatiger08
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
在现有项目上从 5.1 更新到 5.2 时,我们发现composer update
在删除提供程序的行之前和之后运行
Illuminate\Routing\ControllerServiceProvider::class Illuminate\Foundation\Providers\ArtisanServiceProvider::class
Illuminate\Routing\ControllerServiceProvider::class Illuminate\Foundation\Providers\ArtisanServiceProvider::class
was a necessary sequence to getting the laravel update to complete.
是完成 Laravel 更新的必要顺序。
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)
运行 before 将允许 laravel 下载和更新当前的框架库依赖项,然后在删除后运行(composer 能够毫无问题地完成)
We also found that any value in the .env file cannot have spaces and must be surrounded with quotes to work.
我们还发现 .env 文件中的任何值都不能有空格,必须用引号括起来才能起作用。
回答by Jinu P C
Remove the two service providers from config/app.php
从 config/app.php 中删除两个服务提供者
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
回答by Adam Patterson
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.
更新 config/ 下的 app.php 文件解决了一个问题,但随着 bootstrap/cache 文件夹的引入,您可能会继续遇到相同的错误。
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.
我在删除缓存文件之前运行了 composer update ,所以我一直遇到同样的错误。确保先删除 bootstrap/cache/services.php 文件。
There might be a artisan command for this but I totally missed this step in the documentation.
可能有一个工匠命令,但我完全错过了文档中的这一步。
回答by Erhnam
I found the solution here:
我在这里找到了解决方案:
https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0
https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0
Service Providers
服务供应商
The Illuminate\Foundation\Providers\ArtisanServiceProvidershould be removed from your service provider list in your app.php configuration file.
该照亮\基金会\供应商\ ArtisanServiceProvider应该从服务提供商列表中的app.php配置文件中删除。
The Illuminate\Routing\ControllerServiceProvidershould be removed from your service provider list in your app.php configuration file.
该照亮\路径\ ControllerServiceProvider应该从服务提供商列表中的app.php配置文件中删除。
回答by Daniel Ortegón
Remove packages.php and config.php from the bootstrap cache folder after run composer dump-autoload
运行 composer dump-autoload 后从 bootstrap 缓存文件夹中删除 packages.php 和 config.php