2

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.

sepehr
  • 17,110
  • 7
  • 81
  • 119
ITWitch
  • 1,729
  • 5
  • 20
  • 38
  • Can you verify that `laravelcollective/html` package exists in your `vendor/` directory? If so, run `composer dump-autoload` and see if the error persists. – sepehr Nov 12 '16 at 11:49
  • 1
    Yes, inside the `vendor` folder, there is a folder named `laravelcollective` with `html` folder inside it. I executed `composer dump-autoload` again, and it simply returned "Generating autoload files". Nothing more. – ITWitch Nov 12 '16 at 12:04
  • I've added an answer. See below. – sepehr Nov 12 '16 at 12:09

1 Answers1

4

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/.

sepehr
  • 17,110
  • 7
  • 81
  • 119
  • Thank you. I'll try redoing everything. As for the extra `project/` folder, I have it so that my URL won't have the word"public" in it. If there's another way to get rid of "public" without using an extra folder, that would be very great. – ITWitch Nov 12 '16 at 12:15
  • Oh, sure there's a way. You have to set your web document root to `public/` not the project root. As you're using Xampp, you need to create a VirtualHost pointing to your `public/` directory. Here's a guide on how to do that: https://delanomaloney.com/2013/07/10/how-to-set-up-virtual-hosts-using-xampp/ – sepehr Nov 12 '16 at 12:22
  • Also, you might want to consider using Laravel's very own **Valet** for windows: https://github.com/vitr/valet4windows – sepehr Nov 12 '16 at 12:23
  • Update: I tried these steps in a fresh Laravel project, and it's working. I'm not sure, but I think my extra `project` folder was invloved in that error. I am now following the tutorial on creating XAMPP VirtualHost to get rid of the `public` word in my url, without creating an extra folder. – ITWitch Nov 14 '16 at 04:36
  • By the way, when I run `php artisan tinker`, it doesn't seem to finish at all for the next 30 minutes to one hour, so I just terminate it. How long does it usually take to complete? – ITWitch Nov 14 '16 at 08:16
  • 1
    A few seconds. `tinker` command boots your laravel app and gives you a shell interface to interact with it. If it takes that long to load, there's something wrong with your app boot process. – sepehr Nov 14 '16 at 12:02