17

I know there are a bunch of other questions floating around out there with the same error, such as: Class 'Illuminate\Html\HtmlServiceProvider' not found Laravel 5

My problem is that I've followed all suggested steps to solve this on my local (XAMPP), and it fixed it without a hitch. The issue is when I went to deploy to my AWS ubuntu box (nginx). I followed all the usual instructions: http://laravelcollective.com/docs/5.1/html#installation

My providers and aliases had been added when I did a git pull from what I had pushed from my local. Perhaps this file should have been gitignored, and the change made manually on the server?

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

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

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

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

I then manually added:

Begin by installing this package through Composer. Edit your project's composer.json file to require laravelcollective/html.

"require": {
    "laravelcollective/html": "5.1.*"
}

And finally, I ran:

composer.phar update

It was running this command that throws the error:

PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
> php artisan clear-compiled
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
PHP Fatal error:  Class 'Collective\Html\HtmlServiceProvider' not found in /usr/share/nginx/html/cbt/vendor/compiled.php on line 6



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



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



  [RuntimeException]
  Error Output: PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
  PHP Fatal error:  Class 'Collective\Html\HtmlServiceProvider' not found in /usr/share/nginx/html/cbt/vendor/compiled.php on line



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-auties] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [packages1] ...

I then tried running php artisan clear-compiled, to see if that would do anything, and got:

PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
PHP Fatal error:  Class 'Collective\Html\HtmlServiceProvider' not found in /usr/share/nginx/html/cbt/vendor/compiled.php on line 6716



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

I know my nginx ubuntu environment is not the same as a windows xampp env, but I'm still unsure why following the Laravel-provided instructions for adding this don't seem to working. Would greatly appreciate some advice on this.

Cheers!

Community
  • 1
  • 1
carbide20
  • 1,717
  • 6
  • 29
  • 52

5 Answers5

57

When you update your composer it will check the providers. Because you haven't installed laravelcollective/html yet he can't find it and throws an error:

So first require your packeges, then add them to the config file.

You can also work with composer require laravelcollective/html, it will add it to the json file automatically. Then it doesn't matter if you have added them before or not because the config file won't be checked.

cre8
  • 13,012
  • 8
  • 37
  • 61
  • 1
    Exactly what I had to do, thank you so much! I should have known order of operations always matter. – carbide20 Sep 27 '15 at 10:34
  • I would add to this that after running `composer require larevelcollective/html' you also need to add ':5.2' or whatever version you are using. I'm using Laravel 5.2 and this answer gave me the correct solution, but I had to add the version at the end. – logos_164 May 29 '19 at 04:07
14

I have encountered the same error on Laravel 5.2.*, followed instruction here: https://laravelcollective.com/docs/5.2/html, but did not work.

The other way to fix it, on your CLI, run:

$ composer dump-autoload

Then run:

$ composer update

This works for me. ;)

Gengjun Wu
  • 311
  • 3
  • 6
5

If you're using Laravel 5.2, try adding this to your composer.json

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "laravelcollective/html": "^5.2",
    ... 
},
smartrahat
  • 5,381
  • 6
  • 47
  • 68
ecairol
  • 6,233
  • 1
  • 27
  • 26
  • close but you need to require laravelcollective/html: 5.2, I tried this way and it didn't work until I required in the console – logos_164 May 29 '19 at 04:16
0

Installation failed, reverting ./composer.json to its original content.

[ErrorException]
copy(/home/zahid/.composer/cache/files/laravelcollective/html/20e9e29d83e23aba16dc4b8d93d0757e1541f076.zip): failed to open stream: Permiss ion denied

Command: composer require laravelcollective/html --prefer-source

then it work

Shoukat Mirza
  • 800
  • 9
  • 19
Zahid Gani
  • 169
  • 6
0

First try composer update . It will update all dependencies but in case it doesn’t work delete vendor folder of your project and type composer install and run in cli which again add dependencies.

Vhndaree
  • 594
  • 1
  • 6
  • 20