Class 'Illuminate\Html\HtmlServiceProvider'

2019-01-07 13:35发布

Im trying to add the HtmlServiceProvider with Laravel 5. I keep getting the following error:

FatalErrorException in compiled.php line 6391: Class 'Illuminate\Html\HtmlServiceProvider' not found

This is how my providers look like:

'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',

],

This is how my aliases look 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',

],

At last i have added this inside my composer.json

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

Somehow i keep getting this error so im hoping someone can help me out with this :)

Thanks in advance!

12条回答
我想做一个坏孩纸
2楼-- · 2019-01-07 13:48

You can follow below link of Laravel documentation there you can find the solution for all version or Laravel i.e 5.0, 5.1, 5.2, 5.3

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

查看更多
神经病院院长
3楼-- · 2019-01-07 13:49

Try the following steps Edit your project's composer.json file.

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

}

Next, update Composer from the Terminal:

composer update

Next, add your new provider to the providers array of config/app.php:

'providers' => [ // ... 'Collective\Html\HtmlServiceProvider', // ... ],

Finally, add two class aliases to the aliases array of config/app.php:

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

],

查看更多
够拽才男人
4楼-- · 2019-01-07 13:50

First add this line to composer.json

"illuminate/html": "~5.0"

Then do a composer update Wait for the update to finish, then open config/app.php add this:

'Illuminate\Html\HtmlServiceProvider', 

to the providers array and this:

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

to the aliases array, and be sure when you use Html in blade or wherever use it in lowercase 'Html' not HTML

Here is a reference link: http://thegeekyland.blogspot.com/2015/11/class-illuminatehtmlhtmlserviceprovider.html

查看更多
萌系小妹纸
5楼-- · 2019-01-07 13:55

You can also use like this
Illuminate\Html\HtmlServiceProvider::class, and

'Form'      => Illuminate\Html\FormFacade::class,
'Html'      => Illuminate\Html\HtmlFacade::class,
查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-01-07 13:55

For use laravel html helper you need to require dependency in composer.json file and use namespance.For full process follow my blog. http://www.kingpabel.com/laravel-html-helper/

查看更多
再贱就再见
7楼-- · 2019-01-07 13:56

Me I found another cause for this issue:

in ../Vendor directory sometimes there is a file called "config.php", either delete that file completely or find in there some thing like this line:

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

, and remove the line, and then do the "composer update" command, this will help. (It helped me too).

查看更多
登录 后发表回答