hemant
hemant

Reputation: 33

Laravel 5.4 Class 'form' not found

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>

Upvotes: 0

Views: 35403

Answers (5)

Parveen Chauhan
Parveen Chauhan

Reputation: 1496

class aliases in the config/app.php

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

this is working for me

Upvotes: 0

anoja madusanka
anoja madusanka

Reputation: 149

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

Upvotes: 0

Hitarthi Panchal
Hitarthi Panchal

Reputation: 392

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,

Upvotes: 17

Nadeem Qasmi
Nadeem Qasmi

Reputation: 2427

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,

Upvotes: 0

Shogunivar
Shogunivar

Reputation: 1222

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

Upvotes: 4

Related Questions