laravel

Fatal error: Class 'Collective\Html\HtmlServiceProvider' not found in Laravel when deploying with heroku


Here is my composer.json:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",

    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "pusher/pusher-php-server": "~2.0",
        "vinkla/pusher": "^2.2",
        "laravelcollective/html": "^5.2",
        "illuminate/html": "^5.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "symfony/css-selector": "2.8.*|3.0.*",
        "symfony/dom-crawler": "2.8.*|3.0.*",
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "pusher/pusher-php-server": "~2.0",
        "vinkla/pusher": "^2.2",
        "illuminate/html": "^5.0",
        "laravelcollective/html": "^5.2"

    },

    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

And here is the problem:

[Symfony\Component\Debug\Exception\FatalThrowableError]             
remote:  Fatal error: Class 'Collective\Html\HtmlServiceProvider' not found  
remote:                                                                              
remote:        
remote:  Script php artisan clear-compiled handling the post-install-cmd event returned with an error
remote: 

Solution

  • add a new provider to the providers array of config/app.php:

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

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

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