Class form or html not found in Laravel 5

Rakesh Sharma      5 Comments  

Class form or html not found in Laravel 5 :-

Recently i am working with new laravel 5 and found there is more changes or you can say it’s whole rebuild new version. also if you are working with form or html classes you will get Class form or html not found in Laravel 5.

Why error Class Form or HTML not found in Laravel 5 ?

Because of default in Laravel 5 Html and Form are not embedded anymore. Now form builder is a separate package. you need to Pull in “illuminate/html” to get it back.

For this i am sharing below steps how we can pull it back or how we can resolve error Class Form or HTML not found in Laravel 5.

1. Open your “root/composer.json” and add below line in “require” section :

"illuminate/html": "5.*"

Example :- so now your file code of require section looks like:-

"require": {
		"illuminate/html": "5.*",
		"laravel/framework": "5.0.*"
	},

2. Now you need to run “composer update” coomand. for this pick up your laravel application directory path in CLI or terminal and run

composer update

Class Form or HTML not found in Laravel 5

Now after successfully install “Illuminate\Html” you need to add this Laravel Framework Service Providers list. for this go to “config/app.php” and add below code to “providers” array to further use:

'Illuminate\Html\HtmlServiceProvider',

Upper laravel 5.0 :

 Illuminate\Html\HtmlServiceProvider::class,

Example :- so now your file code of provider array section looks like:-


'providers' => [
   /* more already here */
   'Illuminate\Html\HtmlServiceProvider',

3. Now go to “config/app.php” and below code to “aliases” array:


'Html' => 'Illuminate\Html\HtmlFacade',
'Form' => 'Illuminate\Html\FormFacade',

Upper laravel 5.0 :

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

Example :- so now your file code of aliases array section looks like:-


'aliases' => [
   /* more already here */
    'Html' => 'Illuminate\Html\HtmlFacade',
    'Form' => 'Illuminate\Html\FormFacade',
 ],

Now try in your example.blade.php with new syntax {!! $var !!} old style {{$var}} and {{{$var}}} has been deprecated and removed. so use like below example.
Why deprecated ? :- In laravel 4 it included the following two styles: “{{” and “{{{“. The double curly bracket was a raw echo and the triple curly bracket escaped. Currently in laravel 5 both the double and triple curly brackets escape the variable and a new “{!! $var !!}” is for raw.

{!! Form::open() !!}
{!! Form::text('name', @$name) !!}
{!! Form::submit('Send') !!}
{!! Form::close() !!}

Now run your file and you have solved error Class Form or HTML not found in Laravel 5.

  • “old style {{$var}} and {{{$var}}} has been deprecated”
    That’s not really true. They just escape data so Form helpers won’t be formatted to HTML.

  • Pingback: How to include css and js in Laravel 5()

  • Arun Menon

    Iam still getting the same issu

  • Hey,

    What do you mean by this:

    Upper laravel 5.0 :
    IlluminateHtmlHtmlServiceProvider::class,

    What is “Upper” Laravel 5? Where does the ::class bit go?

    • andrewbibby

      i think he means versions of laravel 5 or above – i think
      older versions use quotes.