Laravel ERROR: Class 'Collective\Html\HtmlServiceProvider' not found after running composer require laravelcollective/html in CMD

Question

NOTE: No answer from this thread has helped me, so far. And, I think more than 4 hours of unproductive searching for solution finally validates me to ask further help...

I was following this tutorial in order to use a form in my Laravel project and allow me to save some user inputs in my database. As instructed, I executed this line via CMD:

composer require "laravelcollective/html":"^5.3.0"

Then, I've added these inside config/app.php:

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

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

In my view, I have this, just to check if everything is now ready to be used:

{!! Form::open([]) !!}
{!! Form::text('name', @$name) !!}
{!! Form::password('password') !!}
{!! Form::submit('Send') !!}
{!! Form::close() !!}

But then, it gave me this error:

FatalThrowableError in ProviderRepository.php line 146: Class 'Collective\Html\HtmlServiceProvider' not found

I even added this to my composer.json, just in case this might be the "missing ingredient":

"require": {
    "laravel/framework": "5.0.*",
    "laravelcollective/html": "~5.0"
}

But it did not solve anything either.

Please also note that I found two composer.json files: one inside...

C:\xampp\htdocs\laravelproject

and another inside...

C:\xampp\htdocs\laravelproject\project

... so I edited both.

Side Note: The "project" folder is where the "original" root files can be found (e.g. the folders app, config, resources, etc.. I have previously relocated them in order to remove the word "public" from my URL.

PS: I am very new to Laravel, Composer, and CMD. My only background is in PHP and CodeIgniter.

Please help.

I'm not sure if I should provide here the CMD result after running composer require "laravelcollective/html":"^5.3.0" (because it's 142 lines long), but I have a copy, just in case.


Show source
| php   | laravel-5.3   | laravel-form   2016-11-12 12:11 1 Answers

Answers to Laravel ERROR: Class 'Collective\Html\HtmlServiceProvider' not found after running composer require laravelcollective/html in CMD ( 1 )

  1. 2016-11-12 13:11

    Clearly, Laravel's Illuminate/Foundation/ProviderRepository.php is nagging about the not-found provider:

    138     /**
    139      * Create a new provider instance.
    140      *
    141      * @param  string  $provider
    142      * @return \Illuminate\Support\ServiceProvider
    143      */
    144     public function createProvider($provider)
    145     {
    146         return new $provider($this->app);
    147     }
    

    I've just successfully tested it on a brand new installation of Laravel 5.3. Follow this checklist:

    1. Issue composer require "laravelcollective/html":"^5.3.0".
    2. Verify that the vendor/laravelcollective/html directory exists.
    3. Verify that your composer.json file has been updated and there's an entry for laravelcollective/html package in your dependencies (require block).
    4. Add Collective\Html\HtmlServiceProvider::class to your providers array of config/app.php.
    5. Add 'Form' => Collective\Html\FormFacade::class and 'Html' => Collective\Html\HtmlFacade::class to your aliases array.
    6. Confirm that the API exists: Issue a php artisan tinker command and try playing with Form:: APIs. See if throws any errors.

    You might have already done all these steps. If that's the case, just remove the package with a composer remove laravelcollective/html command and redo all the steps again.

    And most importantly, get an idea of where your project files reside. Get rid of that extra project/.

Leave a reply to - Laravel ERROR: Class 'Collective\Html\HtmlServiceProvider' not found after running composer require laravelcollective/html in CMD

◀ Go back