5

I understand that there are several similar questions here but none of them fixed my problem.

I'm trying to add the HtmlServiceProvider with Laravel 5 on Ubuntu 14.04. I keep getting the following error:

dl@dl-VirtualBox:~/l5todo$ composer update
> php artisan clear-compiled
PHP Fatal error:  Class 'Illuminate\Html\HtmlServiceProvider' not found in /home/dl/l5todo/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146



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



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



  [RuntimeException]                                                                       
  Error Output: PHP Fatal error:  Class 'Illuminate\Html\HtmlServiceProvider' not found i  
  n /home/dl/l5todo/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository  
  .php on line 146          

My vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository
.php looks like:

   /**
 * Create a new provider instance.
 *
 * @param  string  $provider
 * @return \Illuminate\Support\ServiceProvider
 */
public function createProvider($provider)
{
    return new $provider($this->app);//line 146
}

My /.../config/app.php looks like:

'providers' => [

    Illuminate\Html\HtmlServiceProvider::class, //newly added

   ......
],
'aliases' => [

    'App'       => Illuminate\Support\Facades\App::class,
    'Artisan'   => Illuminate\Support\Facades\Artisan::class,
    'Auth'      => Illuminate\Support\Facades\Auth::class,
    'Blade'     => Illuminate\Support\Facades\Blade::class,
    'Bus'       => Illuminate\Support\Facades\Bus::class,
    'Cache'     => Illuminate\Support\Facades\Cache::class,
    ......
  'Form' => Illuminate\Html\FormFacade::class,
    'Html' => Illuminate\Html\HtmlFacade::class,


],

In my compose.Jason

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",

    "Illuminate/Html": "~5.0"
},

Any help would be really appreciated. Sorry again if this question seems duplicated to you.


composer update works if I remove provider and aliases I added. But after I add them back in, same error appears.

Daolin
  • 614
  • 1
  • 16
  • 41
  • I'm sorry for asking really stupid questions but they do have to be asked... 1) did you do `composer install` (or `composer update`)? 2) did you do `composer dump-autoload` afterwards? – Joel Hinz Sep 14 '15 at 20:13
  • Yes, `composer dump-autoload` works fine but `composer install` and `composer update` I got the class not found exception. – Daolin Sep 14 '15 at 20:17
  • is composer.json case sensitive? In other words, does `"illuminate/html"` make a difference? – Chris Burton Sep 14 '15 at 20:22
  • Also, you should run a composer install/update *before* adding the service provider in app.php. – Chris Burton Sep 14 '15 at 20:25
  • I think it might be case sensitive so I kept them consistent. I did the update after modified app.php. should I remove provider then update? – Daolin Sep 14 '15 at 20:28
  • 1
    Yes, remove the service provider along with the Facades. After composer update, add them back in. – Chris Burton Sep 14 '15 at 20:29
  • `composer update` works if I remove provider and aliases I added. But after I add them back in, same error appears. – Daolin Sep 14 '15 at 20:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89623/discussion-between-daolincheng-and-chris-burton). – Daolin Sep 14 '15 at 20:37

2 Answers2

7

Step 1

In composer.json under require, add:

"laravelcollective/html": "5.1.*",

Step 2

run composer update in your terminal

Step 3

Add the following in config/app.php under providers:

Collective\Html\HtmlServiceProvider::class,

Step 4

Add the following in config/app.php under aliases:

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

Chris Burton
  • 1,195
  • 6
  • 19
  • 54
0

Step 1 composer.json

"illuminate/html": "~5.0"

Step 2 process dump-autoload

composer.phar dump-autoload

Step 3 app.php

Illuminate\Html\HtmlServiceProvider::class,

and

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

Step 4 flush caching (if needed)

composer.phar dump-autoload
php artisan config:clear
php artisan clear-compiled
patriziotomato
  • 591
  • 1
  • 11
  • 25