In this article, we will fix the laravel 9 form class not found error, many times we have received errors like laravel 9 class 'form' not found. The Laravel Collective package HTML comes packed with an HTML and FORM generator allowing you to handle easy-to-manage forms in your blade files as well as intricate model binding to your forms.
We have received this error message because of laravel 9 version made changes in their library file, you can solve this issue by using the "laravelcollective/html" package. laravelcollective/html package will provide you with HTML and FORM class helper.
laravelcollective/html is provide html textbox, radio button, select box, checkbox, and many more with laravel. They provide different methods to use those input fields we need to add this facade class 'collective\html\formfacade' if not added.
So, let's see the class 'form' not found in laravel 9 and how to install laravel collective in laravel 9.
For the laravel 9 form class not found run the below command and install the latest and supported version of "laravelcollective html".
composer require laravelcollective/html
If you are using the 5.x version then you need to add the below code In the app.php file.
'providers' => [ ... Collective\Html\HtmlServiceProvider::class, ... ], 'aliases' => [ ... 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, ... ],
If you are using a lower laravel collective version like v5.6, v5.5, or below then add code like the below.
Goto your project's composer.json file to require laravelcollective/html.
composer require "laravelcollective/html":"^5.8.0"
Now, add your new provider to the provider's array of config/app.php :
'providers' => [ // ... Collective\Html\HtmlServiceProvider::class, // ... ],
After that, add two class aliases to the aliases array of config/app.php
'aliases' => [ // ... 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, // ... ],
If you can use greater than the v5.6 version then we just need to run single command no other changes are required in any files.
$ composer require laravelcollective/html
You might also like :