30

I'm 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!

Rashed Hasan
  • 3,721
  • 11
  • 40
  • 82
kazehaya
  • 511
  • 2
  • 7
  • 14
  • 3
    Did you run `composer update` after adding it to your `composer.json`? – lukasgeiter Feb 16 '15 at 12:07
  • 1
    Thanks to your comment i double checked it and i was doing composer update all the time in the wrong project folder inside homestead! Got it working now :) – kazehaya Feb 16 '15 at 12:11
  • 4
    `illuminate/html` is deprecated https://laravel-news.com/2015/02/new-community-project-laravel-collective/ – user2094178 Feb 17 '15 at 02:18
  • This is a big problem in terms of automating deployments, does anyone have a solution? – tread Nov 09 '15 at 15:27
  • @surfer190 no it's not. Deployments should use `composer install` not `composer update` to install the exact versions specified in `composer.lock`. There are no pre-install-cmd scripts so `install` doesn't attempt to load the config files. Now in this specific case, where the package name/namespace was changed, that should be caught before deploying... – andrewtweber Nov 09 '15 at 21:29

11 Answers11

42

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

Arlind Hajredinaj
  • 8,380
  • 3
  • 30
  • 45
  • 5
    Please note that, as this answer says, you first add the `composer.json` line, then do an update, then add the lines to `app.php`. You can't combine the two steps and have it work. – Rob Cranfill Oct 17 '15 at 22:22
  • 1
    Please note the answer with laravelcollective/html package as the Illuminate one is now depreciated. – tristanbailey Jan 29 '16 at 09:11
30

Illuminate\Html\HtmlServiceProvider is not a core element anymore. Laravel components that have been removed from the core framework are available on laravelcollective.com your html & forms components can be found here:

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

add this to your composer.json :

"laravelcollective/html": "~5.0"

then update composer:

composer update

then add providers in config/app.php

'Collective\Html\HtmlServiceProvider',

and finally add two aliases in the same file:

'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
arslion
  • 409
  • 6
  • 16
14

Illuminate/HTML package has been deprecated

Use:laravelcollective/html

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

composer require laravelcollective/html

Add this lines in config/app.php

in providers group:

Collective\Html\HtmlServiceProvider::class,

in aliases group:

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
Community
  • 1
  • 1
Kyizin
  • 371
  • 4
  • 16
3

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

],

Tijo John
  • 686
  • 1
  • 9
  • 20
  • This is a good answer, I think you should rate the correct answer made above than trying to get your own answer which isn't more precise as Arlind did. – blakroku Aug 30 '15 at 09:00
1

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).

gildniy
  • 3,528
  • 1
  • 33
  • 23
  • I can't believe I'm the first person to up-vote this answer. In my case I had already switched from the Illuminate to the LaravelCollective version, but still got the issue whilst deploying to my test environment. The solution was to rm boostrap/cache/*, which just removes config.php and services.json. For some reason, even though I had removed all references to the old version and successfully run composer update, artisan clear-compiled was still failing. Removing those two files in boostrap/cache two files solved the problem. – JamesG Aug 03 '16 at 05:24
  • They were not interested in this answer as Illuminate\Html was removed from core Laravel. Thanks for up-vote. – gildniy Aug 09 '16 at 13:54
1

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

'Form'      => Illuminate\Html\FormFacade::class,
'Html'      => Illuminate\Html\HtmlFacade::class,
Md Sirajus Salayhin
  • 4,974
  • 5
  • 37
  • 46
0

The error indicates it can't find the service provider so make sure you do a composer update. If you did do a composer update check your vendor folder to make sure it pulled in the dependency.

Jeremy Schaffer
  • 428
  • 4
  • 9
0

Double check when Updating your composer, whether you're in the right directory

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Awais Tahir
  • 180
  • 1
  • 10
  • It's really silly, but that was my problem :-P I couldn't imagine that such thing can happen to me :) – balping Jun 12 '15 at 14:51
0

Run this in cmd

php artisan  Illuminate\Html 

and then add variables in app.php

ryanyuyu
  • 6,366
  • 10
  • 48
  • 53
0

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

kantsverma
  • 606
  • 1
  • 11
  • 31
-1

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/

Imtiaz Pabel
  • 5,307
  • 1
  • 19
  • 24