0

I have recently decided to upgrade from laravel 5.1 to 5.2. My composer.json file is as follows:

{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": ["framework", "laravel"],
  "license": "MIT",
  "type": "project",
  "require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "laracasts/flash": "dev-master",
    "laravelcollective/html": "5.2.0",
    "intervention/image": "^2.3",
    "cviebrock/image-validator": "^2.0"

  },
  "require-dev": {
      "fzaninotto/faker": "~1.4",
      "mockery/mockery": "0.9.*",
      "phpunit/phpunit": "~4.0",
      "phpspec/phpspec": "~2.1",
      "symfony/dom-crawler": "~3.0",
      "symfony/css-selector": "~3.0"
 },
 "autoload": {
    "classmap": [
        "database"
    ],
    "files": ["app/Http/helpers.php"],
    "psr-4": {
        "App\\": "app/"
    }
 },
 "autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
 },
 "scripts": {
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
 },
 "config": {
    "preferred-install": "dist"
 },
 "minimum-stability": "dev",
 "prefer-stable": true
}

My providers array in my app.php file is as follows:

'providers' => [

    Illuminate\Auth\AuthServiceProvider::class,
    // some more...
    Illuminate\View\ViewServiceProvider::class,
    Collective\Html\HtmlServiceProvider::class,

    Laracasts\Flash\FlashServiceProvider::class,
    Intervention\Image\ImageServiceProvider::class,
    Cviebrock\ImageValidator\ImageValidatorServiceProvider::class,

],

'aliases' => [

    'App'       => Illuminate\Support\Facades\App::class,
    // some more...
    'Form'      => Collective\Html\FormFacade::class,
    'Html'      => Collective\Html\HtmlFacade::class,
    'Image'     => Intervention\Image\Facades\Image::class,
],

I do composer update and get the following error:

> C:\ProgramData\ComposerSetup\bin\composer.bat update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
> php artisan clear-compiled


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


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

I get the same error when I try to run php artisan serve. I've tried all the usual stuff such as composer dump-autoload etc.

Why is this happening and whats the fix?

adam78
  • 9,668
  • 24
  • 96
  • 207
  • Possible duplicate of [Class 'Illuminate\Html\HtmlServiceProvider' not found Laravel 5](http://stackoverflow.com/questions/28541051/class-illuminate-html-htmlserviceprovider-not-found-laravel-5) – Jonathan Solorzano Feb 17 '17 at 15:29
  • 1
    Try deleting vendor and running `composer install` first – apokryfos Feb 17 '17 at 15:38
  • @feniix already checked every possible solution on SO including the one you have linked to and it doesnt work. – adam78 Feb 17 '17 at 15:42
  • @apokryfos tried deleting and running `composer install` still get same error. – adam78 Feb 17 '17 at 15:54
  • `Illuminate\Html\HtmlServiceProvider` is obviously cached somewhere since there shouldn't be any reference to it in your code. Try clearing the entire `storage` and `bootstrap/cache` directories as well. Also a global search for `Illuminate\Html\HtmlServiceProvider` couldn't hurt either – apokryfos Feb 17 '17 at 16:26

2 Answers2

0

Taken from Class 'Illuminate\Html\HtmlServiceProvider' not found Laravel 5

First add this line to composer.json

"laravelcollective/html": "5.2.0"

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

Collective\Html\HtmlServiceProvider::class 

to the providers array and this:

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

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

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.

Community
  • 1
  • 1
Jonathan Solorzano
  • 6,812
  • 20
  • 70
  • 131
  • I've already tried all the solutions from all the other similar post regarding this issue including the above and nothing works. – adam78 Feb 17 '17 at 15:41
  • @adam78 I dont see illuminate/html in your composer.json. Can you even find the class anywhere in your laravel install directory? Make sure you have it at least. – Chad Fisher Feb 17 '17 at 15:56
  • @Chad Fisher it doesn't exist inside the vendor directory becuase it's been depracated. Thats why I use LaravelCollective – adam78 Feb 17 '17 at 16:02
  • @adam78 Do you have something against adding it to your project? It seems something is requiring it still. – Chad Fisher Feb 17 '17 at 16:05
0

Managed to fix. I did a search in the entire project to see if it was still being referenced anywhere. Lo and behold it was still being referenced in a macroserviceprovider so I changed it to use use Collective\Html\HtmlServiceProvider; instead.

adam78
  • 9,668
  • 24
  • 96
  • 207