Using Forms in Laravel 5 Blade Templating Engine

With new version bump up in laravel, Form and HTML Facades has been removed as core feature of Laravel, if you are getting ERROR : Class 'Form' not found or Class html does not exist, it's probably because html package is not installed.  

I used it quite a bit fortunately this package is still maintained separately and we can get it using composer. Let's see how to get and integrate it with our Laravel 5 application.

Step 1: add dependency in composer.json

"require": {
         
        "laravel/framework": "~5.0",

        "illuminate/html": "5.*", // Add this line

}

 

Step 2: Now run composer update in your console or command prompt 


composer update

 

Step 3: It will take minutes or two to get the package, lets add reference of it in our Application Service Provider.

Open config/app.php and add this line to providers.

<?php

return [
   'providers' => [
     // Other service providers 

     'Illuminate\Html\HtmlServiceProvider', // Add this line at bottom
    ]
]

  

In the same file config/app.php, add alias  in aliases. 

<?php

return [
   'aliases' => [
        // Other aliases 
        // Add both lines
        'Form'      => 'Illuminate\Html\FormFacade',       
        'HTML'      => 'Illuminate\Html\HtmlFacade',
    ]
]

 

Just like that we are done, Now you can use it in your project.

don't forget to run composer dump-autoload in case you get errors.

Something to say? Tell us in comment section.