I have added \"illuminate/html\": \"5.*\" to composer.json and ran \"composer update\".
- Installing illuminate/html (v5.0.0)
Loading from cache
Just type the following command in terminal at the project directory and installation is done according the Laravel version:
composer require "laravelcollective/html"
Then add these lines in config/app.php
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
You can also try running the following commands in Terminal or Command:
composer dump-auto
or composer dump-auto -o
php artisan cache:clear
php artisan config:clear
The above worked for me.
Form
isn't included in laravel
5.0 as it was on 4.0, steps to include it:
Begin by installing laravelcollective/html
package through Composer
. Edit your project's composer.json
file to require:
"require": {
"laravelcollective/html": "~5.0"
}
Next, update composer
from the Terminal:
composer update
Next, add your new provider to the providers
array of config/app.php
:
'providers' => [
// ...
'Collective\Html\HtmlServiceProvider',
// ...
],
Finally, add two class aliases to the aliases
array of config/app.php
:
'aliases' => [
// ...
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
// ...
],
At this point, Form
should be working
Source
Update Laravel 5.8
(2019-04-05):
In Laravel 5.8
, the providers
in the config/app.php
can be declared as:
Collective\Html\HtmlServiceProvider::class,
instead of:
'Collective\Html\HtmlServiceProvider',
This notation is the same for the aliases.
There is an update to this for Laravel 5.2. Notice this is a slightly different format from what is indicated above.
Begin by installing this package through Composer. Edit your project's composer.json file to require laravelcollective/html.
"require": {
"laravelcollective/html": "5.2.*"
}
Next, update Composer from the Terminal:
composer update
Next, add your new provider to the providers array of config/app.php:
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
After making this update this code worked for me on a new installation of Laravel 5.2:
{!! Form::open(array('url' => 'foo/bar')) !!}
//
{!! Form::close() !!}
I got this information here: https://laravelcollective.com/docs/5.2/html
In Laravel Version - 4, HTML and Form existed, but not now.
Why:
The only reason is they have collected some user requirements and they want it more lightweight and so they removed it as in the sense that a user can add it manually.
What to do to add HTML & Forms in Laravel 5.2 or 5.3:
For 5.2:
Go to the Laravel Collective site and installation processes have demonstrated their.
Like for 5.2: on the command line, run the command
composer require "laravelcollective/html":"^5.2.0"
Then, in the provider array which is in config/app.php. Add this line at last using a comma(,):
Collective\Html\HtmlServiceProvider::class,
For using HTML and FORM text we need to alias them in the aliases array of config/app.php. Add the two lines at the last
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
And for 5.3:
Just run the command
composer require "laravelcollective/html":"^5.3.0"
And the rest of the procedure is like 5.2.
Then you can use Laravel Form and other HTML links in your projects. For this, follow this documentation:
5.2: https://laravelcollective.com/docs/5.2/html
5.3: https://laravelcollective.com/docs/5.3/html
Demo Code:
To open a form, open and close a tag:
{!! Form::open(['url' => 'foo/bar']) !!}
{!! Form::close() !!}
And for creating label and input text with a Bootstrap form-control class and other use:
{!! Form::label('title', 'Post Title') !!}
{!! Form::text('title', null, array('class' => 'form-control')) !!}
And for more, use the documentation, https://laravelcollective.com/.
This may not be the answer you're looking for, but I'd recommend using the now community maintained repository Laravel Collective Forms & HTML as the main repositories have been deprecated.
Laravel Collective is in the process of updating their website. You may view the documentation on GitHub if needed.