laravel 从 Illuminate\Html 切换到 Collective\Html,找不到类 'Illuminate\Html\HtmlServiceProvider'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32283767/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:16:24  来源:igfitidea点击:

Switching from Illuminate\Html to Collective\Html, Class 'Illuminate\Html\HtmlServiceProvider' not found

laravellaravel-5laravel-5.1laravelcollective

提问by Dylan

I updated composer.jsonto remove illuminate\html and add:

我更新composer.json了删除illuminate\html并添加:

"require": {
    "laravelcollective/html": "5.1.*"

I removed the providers/aliases from app.phpfor Illuminate\Html and added the replacements:

我从app.phpIlluminate\Html 中删除了提供者/别名并添加了替换:

    Collective\Html\HtmlServiceProvider::class,

...

...

    'Form'      => Collective\Html\FormFacade::class,
    'Html'      => Collective\Html\HtmlFacade::class,

However when running composer updateI receive the output:

但是在运行时composer update我收到输出:

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing illuminate/html (v5.0.0)

- Installing laravelcollective/html (v5.1.4)
  Downloading: 100%  

Writing lock file
Generating autoload files
> php artisan clear-compiled
PHP Fatal error:  Class 'Illuminate\Html\HtmlServiceProvider' not found in vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 648

[Symfony\Component\Debug\Exception\FatalErrorException]  
Class 'Illuminate\Html\HtmlServiceProvider' not found                                                     

Script php artisan clear-compiled handling the post-update-cmd event returned with an error

[RuntimeException]                                                                   
Error Output: PHP Fatal error:  Class 'Illuminate\Html\HtmlServiceProvider' not found in vendor/laravel/framework/src/Illuminate/Foundation/Application.php on line 648 

I tried updating composer.jsonscripts as suggested here: https://github.com/LaravelCollective/html/issues/54

我尝试composer.json按照此处的建议更新脚本:https: //github.com/LaravelCollective/html/issues/54

But I'm still receiving the error. Any help is greatly appreciated :)

但我仍然收到错误。任何帮助是极大的赞赏 :)

回答by Dylan

In the end I managed to fix this with some help on IRC (thanks sisve) and these commands. First I rolled back to a working site with illuminate/html. Then:

最后,我在 IRC(感谢 sisve)和这些命令的帮助下设法解决了这个问题。首先,我回滚到一个带有照明/html 的工作站点。然后:

composer dumpautoload
composer clearcache
php artisan clear-compiled

If the clear-compiledfails then make sure there are no references to Illuminate\Html in bootstrap/cache/config.phpand run it again.

如果clear-compiled失败,请确保没有对 Illuminate\Html 的引用bootstrap/cache/config.php并再次运行它。

Remove all references to Illuminate\Html in config/app.php
Remove the illuminate/htmlrequire in composer.json

删除对 Illuminate\Html 中的所有引用config/app.php
删除中的illuminate/htmlrequirecomposer.json

composer update

Add the laravelcollective/html package as described here: http://laravelcollective.com/docs/5.1/html#installation

添加 laravelcollective/html 包,如下所述:http://laravelcollective.com/docs/5.1/html#installation

composer update