0

I'm facing problem 'Class 'form' not found' I'm currently using laravel 5.4. I already have tried maximum efforts to solve.

Thanks

Error is : Whoops, looks like something went wrong.

1/1

FatalErrorException in d0b19e04e5a1f8a5507d8ca427362b23807103ca.php line 23: Class 'Form' not found in d0b19e04e5a1f8a5507d8ca427362b23807103ca.php line 23

Here is my Comp

{
    "require": {
       "php": ">=5.6.4",
       "laravel/framework": "5.4.*",
       "laravel/tinker": "~1.0",
       "laravelcollective/html": "^5.4"
    }, 
}

I run the composer update command.

Here is my app.php

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Notifications\NotificationServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,
    'Collective\Html\HtmlServiceProvider',


    /*
     * Package Service Providers...
     */
    Laravel\Tinker\TinkerServiceProvider::class,

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

],

/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/

'aliases' => [

    'App' => Illuminate\Support\Facades\App::class,
    'Artisan' => Illuminate\Support\Facades\Artisan::class,
    'Auth' => Illuminate\Support\Facades\Auth::class,
    'Blade' => Illuminate\Support\Facades\Blade::class,
    'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
    'Bus' => Illuminate\Support\Facades\Bus::class,
    'Cache' => Illuminate\Support\Facades\Cache::class,
    'Config' => Illuminate\Support\Facades\Config::class,
    'Cookie' => Illuminate\Support\Facades\Cookie::class,
    'Crypt' => Illuminate\Support\Facades\Crypt::class,
    'DB' => Illuminate\Support\Facades\DB::class,
    'Eloquent' => Illuminate\Database\Eloquent\Model::class,
    'Event' => Illuminate\Support\Facades\Event::class,
    'File' => Illuminate\Support\Facades\File::class,
    'Gate' => Illuminate\Support\Facades\Gate::class,
    'Hash' => Illuminate\Support\Facades\Hash::class,
    'Lang' => Illuminate\Support\Facades\Lang::class,
    'Log' => Illuminate\Support\Facades\Log::class,
    'Mail' => Illuminate\Support\Facades\Mail::class,
    'Notification' => Illuminate\Support\Facades\Notification::class,
    'Password' => Illuminate\Support\Facades\Password::class,
    'Queue' => Illuminate\Support\Facades\Queue::class,
    'Redirect' => Illuminate\Support\Facades\Redirect::class,
    'Redis' => Illuminate\Support\Facades\Redis::class,
    'Request' => Illuminate\Support\Facades\Request::class,
    'Response' => Illuminate\Support\Facades\Response::class,
    'Route' => Illuminate\Support\Facades\Route::class,
    'Schema' => Illuminate\Support\Facades\Schema::class,
    'Session' => Illuminate\Support\Facades\Session::class,
    'Storage' => Illuminate\Support\Facades\Storage::class,
    'URL' => Illuminate\Support\Facades\URL::class,
    'Validator' => Illuminate\Support\Facades\Validator::class,
    'View'      => Illuminate\Support\Facades\View::class,
    'FORM' => 'Collective\Html\FormFacade',
    'HTML' => 'Collective\Html\HtmlFacade',
],

];

using form in formupload.blade.php

@if(isset($success))
    <div class="alert alert-success"> {{$success}} </div>
@endif
    {!! Form::open(['action'=>'ImageController@store', 'files'=>true]) !!}

    <div class="form-group">
        {!! Form::label('title', 'Title:') !!}
        {!! Form::text('title', null, ['class'=>'form-control']) !!}
    </div>

    <div class="form-group">
        {!! Form::label('description', 'Description:') !!}
        {!! Form::textarea('description', null, ['class'=>'form-control', 'rows'=>5] ) !!}
    </div>

    <div class="form-group">
        {!! Form::label('image', 'Choose an image') !!}
        {!! Form::file('image') !!}
    </div>

    <div class="form-group">
        {!! Form::submit('Save', array( 'class'=>'btn btn-danger form-control' )) !!}
    </div>

    {!! Form::close() !!}
    <div class="alert-warning">
        @foreach( $errors->all() as $error )
           <br> {{ $error }}
        @endforeach
    </div>

</div>
Shogunivar
  • 1,237
  • 11
  • 18
hemant
  • 33
  • 1
  • 1
  • 4
  • Possible duplicate of [Laravel 5 Class 'form' not found](http://stackoverflow.com/questions/28753767/laravel-5-class-form-not-found) – Rahul Apr 04 '17 at 12:36
  • Please show these _"maximum efforts"_, start by showing some code and an expected result – Shogunivar Apr 04 '17 at 12:37
  • Look at this [link](https://laravelcollective.com/docs/5.3/html) – Rouhollah Mazarei Apr 04 '17 at 12:39
  • Hello Mr. R. Manzarei this link is only for 5.3 version I'm currently using 5.4.17 version of laravel – hemant Apr 04 '17 at 13:24
  • Hi @Shogunivar I have added "require": { "laravelcollective/html": "^5.4" }, to composer.json & added 'providers' => [' 'Collective\Html\HtmlServiceProvider',] & Add to aliases 'FORM' => 'Collective\Html\FormFacade', 'HTML' => 'Collective\Html\HtmlFacade', in app.php also run composer update command in cmd – hemant Apr 04 '17 at 13:25
  • @hemant okay, well you will need to install that, by running composer install. But honestly, we can't help you if we can't see the code where it's going wrong. Edit your question with the code where you're trying to use a form – Shogunivar Apr 04 '17 at 13:30

5 Answers5

17

Put this in composer.json

"require": {
        "laravelcollective/html": "^5.4"
 },

and Run

composer update 

in command afterwards

Or

composer require laravelcollective/html

Then add this in your config/app.php in providers section array

Collective\Html\HtmlServiceProvider::class,

After that add two class aliases in the config/app.php in aliases array

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
Hitarthi Panchal
  • 392
  • 2
  • 11
4

Looks like you set the alias for your Form Class to "FORM" here in your app.php:

'FORM' => 'Collective\Html\FormFacade',

Try changing that to Form like so:

'Form' => 'Collective\Html\FormFacade',

then it should work

Shogunivar
  • 1,237
  • 11
  • 18
  • Hi @Shogunivar Thanks for giving me right answer. Yes, Its working fine. Its right answer. thanks again for great help. – hemant Apr 05 '17 at 04:20
0

run command

 composer require laravelcollective/html

when the composer update the require html laravel collective then add these two line into config/app.php into the section of
'aliases' => [ ],

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

then add the line into config/app.php
'providers' => [ ], and save the file

Collective\Html\HtmlServiceProvider::class,
Nadeem Qasmi
  • 2,217
  • 22
  • 16
0

Run the command

composer require laravelcollective/html

add these two lines into config/app.php into the section of 'aliases' => [ ],

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

add the line into config/app.php 'providers' => [ ], and save the file

Collective\Html\HtmlServiceProvider::class,

this also works for 6.X

Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
0

class aliases in the config/app.php

'Form' => 'Collective\Html\FormFacade',

this is working for me

Parveen Chauhan
  • 1,396
  • 12
  • 25