Class 'Form' not found in Laravel 7

48 views 1 month ago Laravel

In Laravel 5 earlier versions, Laravel Form builder was already installed, but on new Laravel versions it is not preinstalled. SO whenever you add Form builder in blade file, you will get error 'Class Form not found'.

To use Laravel Form builder first you have to install laravelcollective/html to project through Composer.

Put the below lines in composer.json

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

and Run command

composer update

or directly install using command

composer require laravelcollective/html

This will install Laravel Form builder package to use in blade file.

Now open config/app.php file and put the below line in 'providers' array.

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

In the same file add these two class aliases in aliases array.

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

Now, you can use of laravel form builder in your blade file.

{!! Form::open(['url' => 'foo/bar']) !!}
	// ...
{!! Form::close() !!}

I hope it will help you.

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]