Class' Illuminate \ Html \ HtmlServiceProvider'没找到Laravel 5

时间:2015-02-16 12:04:17

标签: laravel composer-php laravel-5

我试图用Laravel 5添加HtmlServiceProvider。 我一直收到以下错误:

compile.php第6391行中的FatalErrorException: 找不到类'Illuminate \ Html \ HtmlServiceProvider'

这就是我的提供商的样子:

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    'Illuminate\Bus\BusServiceProvider',
    'Illuminate\Cache\CacheServiceProvider',
    'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
    'Illuminate\Routing\ControllerServiceProvider',
    'Illuminate\Cookie\CookieServiceProvider',
    'Illuminate\Database\DatabaseServiceProvider',
    'Illuminate\Encryption\EncryptionServiceProvider',
    'Illuminate\Filesystem\FilesystemServiceProvider',
    'Illuminate\Foundation\Providers\FoundationServiceProvider',
    'Illuminate\Hashing\HashServiceProvider',
    'Illuminate\Mail\MailServiceProvider',
    'Illuminate\Pagination\PaginationServiceProvider',
    'Illuminate\Pipeline\PipelineServiceProvider',
    'Illuminate\Queue\QueueServiceProvider',
    'Illuminate\Redis\RedisServiceProvider',
    'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
    'Illuminate\Session\SessionServiceProvider',
    'Illuminate\Translation\TranslationServiceProvider',
    'Illuminate\Validation\ValidationServiceProvider',
    'Illuminate\View\ViewServiceProvider',
    'Illuminate\Html\HtmlServiceProvider',

    /*
     * Application Service Providers...
     */
    'App\Providers\AppServiceProvider',
    'App\Providers\BusServiceProvider',
    'App\Providers\ConfigServiceProvider',
    'App\Providers\EventServiceProvider',
    'App\Providers\RouteServiceProvider',

],

我的别名看起来像ik app.php:

'aliases' => [

    'App'       => 'Illuminate\Support\Facades\App',
    'Artisan'   => 'Illuminate\Support\Facades\Artisan',
    'Auth'      => 'Illuminate\Support\Facades\Auth',
    'Blade'     => 'Illuminate\Support\Facades\Blade',
    'Bus'       => 'Illuminate\Support\Facades\Bus',
    'Cache'     => 'Illuminate\Support\Facades\Cache',
    'Config'    => 'Illuminate\Support\Facades\Config',
    'Cookie'    => 'Illuminate\Support\Facades\Cookie',
    'Crypt'     => 'Illuminate\Support\Facades\Crypt',
    'DB'        => 'Illuminate\Support\Facades\DB',
    'Eloquent'  => 'Illuminate\Database\Eloquent\Model',
    'Event'     => 'Illuminate\Support\Facades\Event',
    'File'      => 'Illuminate\Support\Facades\File',
    'Hash'      => 'Illuminate\Support\Facades\Hash',
    'Input'     => 'Illuminate\Support\Facades\Input',
    'Inspiring' => 'Illuminate\Foundation\Inspiring',
    'Lang'      => 'Illuminate\Support\Facades\Lang',
    'Log'       => 'Illuminate\Support\Facades\Log',
    'Mail'      => 'Illuminate\Support\Facades\Mail',
    'Password'  => 'Illuminate\Support\Facades\Password',
    'Queue'     => 'Illuminate\Support\Facades\Queue',
    'Redirect'  => 'Illuminate\Support\Facades\Redirect',
    'Redis'     => 'Illuminate\Support\Facades\Redis',
    'Request'   => 'Illuminate\Support\Facades\Request',
    'Response'  => 'Illuminate\Support\Facades\Response',
    'Route'     => 'Illuminate\Support\Facades\Route',
    'Schema'    => 'Illuminate\Support\Facades\Schema',
    'Session'   => 'Illuminate\Support\Facades\Session',
    'Storage'   => 'Illuminate\Support\Facades\Storage',
    'URL'       => 'Illuminate\Support\Facades\URL',
    'Validator' => 'Illuminate\Support\Facades\Validator',
    'View'      => 'Illuminate\Support\Facades\View',
    'Form'      => 'Illuminate\Html\FormFacade',
    'Html'      => 'Illuminate\Html\HtmlFacade',

],

最后我在composer.json中添加了这个

"require": {
    "laravel/framework": "5.0.*",
    "illuminate/html": "~5.0"
},

不知怎的,我不断收到这个错误,所以我希望有人可以帮我解决这个问题:)

提前致谢!

12 个答案:

答案 0 :(得分:39)

首先将此行添加到 composer.json

"illuminate/html": "~5.0"

然后做一个composer update 等待更新完成,然后打开 config / app.php 添加:

'Illuminate\Html\HtmlServiceProvider', 

providers数组,然后:

'Form'      => 'Illuminate\Html\FormFacade',
'Html'      => 'Illuminate\Html\HtmlFacade',

aliases数组,并确保何时在刀片中使用Html或在小写的地方使用Html' Html'不是HTML

以下是参考链接:http://thegeekyland.blogspot.com/2015/11/class-illuminatehtmlhtmlserviceprovider.html

答案 1 :(得分:30)

Illuminate \ Html \ HtmlServiceProvider不再是核心元素。已从核心框架中删除的Laravel组件可在laravelcollective.com上找到.html& amp;表单组件可以在这里找到:

http://laravelcollective.com/docs/5.0/html

将此添加到您的composer.json:

"laravelcollective/html": "~5.0"

然后更新作曲家:

composer update

然后在config / app.php中添加提供程序

'Collective\Html\HtmlServiceProvider',

最后在同一个文件中添加两个别名:

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

答案 2 :(得分:12)

不推荐使用Illuminate / HTML包

使用:laravelcollective / HTML

https://stackoverflow.com/a/34991188/3327198

composer require laravelcollective/html

在config / app.php中添加以下行

提供者组中的

Collective\Html\HtmlServiceProvider::class,
别名组中的

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

答案 3 :(得分:3)

请尝试以下步骤 编辑项目的composer.json文件。

"require": {
"laravelcollective/html": "~5.0"

}

接下来,从终端更新Composer:

作曲家更新

接下来,将新的提供程序添加到config / app.php的提供程序数组中:

'商' => [     // ...     '集体\ HTML \ HtmlServiceProvider&#39 ;,     // ...   ],

最后,将两个类别名添加到config / app.php的别名数组中:

'aliases' => [
// ...
  'Form' => 'Collective\Html\FormFacade',
  'Html' => 'Collective\Html\HtmlFacade',
// ...

],

答案 4 :(得分:1)

我发现了这个问题的另一个原因:

在../Vendor目录中有时会有一个名为" config.php"的文件,要么完全删除该文件,要么在那里找到一些像 这一行:

array (
  ...
  28 => 'Illuminate\Html\HtmlServiceProvider',
  ...
),

,然后删除该行,然后执行" composer update"命令,这会有所帮助。 (它也帮助了我。)

答案 5 :(得分:1)

你也可以这样使用
Illuminate\Html\HtmlServiceProvider::class,

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

答案 6 :(得分:0)

错误表明它无法找到服务提供商,因此请确保您进行了作曲家更新。如果你确实做了一个作曲家更新,请检查你的供应商文件夹,以确保它被拉入依赖项。

答案 7 :(得分:0)

在更新作曲家时仔细检查,无论您是否在正确的目录中

答案 8 :(得分:0)

在cmd中运行

php artisan  Illuminate\Html 

然后在app.php中添加变量

答案 9 :(得分:0)

您可以按照下面的Laravel文档链接找到所有版本或Laravel的解决方案,即5.0,5.1,5.2,5.3

https://laravelcollective.com/docs/5.3/html

答案 10 :(得分:-1)

对于使用laravel html帮助程序,您需要在composer.json文件中要求依赖并使用namespance.For完整进程请关注我的博客。 http://www.kingpabel.com/laravel-html-helper/

答案 11 :(得分:-2)

错误的根是HtmlServiceProvider的别名。在“别名”下的config / app.php中,将别名(Html)案例更改为大写

自: 'Html'=> '照亮\ HTML \ HtmlFacade'

于: 'HTML'=> '照亮\ HTML \ HtmlFacade'