问题
I've tried to use the Laravelcollective/html
on laravel 5.5 by loading the v5.4 in my composer.json
file but that didn't work. This is the code in the composer.json
file:
"laravelcollective/html":"^5.4.0",
and loading it into my app configuration file app.php
: inside the providers array
Collective\Html\HtmlServiceProvider::class,
But after i used the blade code to create the form it didn't work, here's the blade code.
{!! Form::open(['route' => 'posts.store']) !!}
{{Form::label('title','Title:')}}
{{Form::text('title', null, array('class' => 'form-control') )}}
{!! Form::close() !!}
回答1:
In composer.json
, add:
"require": {
// ...,
"laravelcollective/html": "^5.4.0"
// ...,
},
In app/config/app.php
, add the following to each array:
'providers' => [
// ...,
Collective\Html\HtmlServiceProvider::class,
// ...
],
'aliases' => [
// ...,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
And in your blade file:
{!! Form::open(['route' => 'posts.store']) !!}
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', null, array('class' => 'form-control')) !!}
{!! Form::close() !!}
Then run $ composer require laravelcollective/html:^5.4.0
after adding the above. :)
回答2:
You can use this command
composer require --update-with-all-dependencies "laravelcollective/html 5.6.*"... since you are using laravel 5.5 the command to use will be
composer require "laravelcollective/html 5.5.*"
回答3:
You also have to add the following to your alias array:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
回答4:
The syntax you are using is old style.
{{Form::label('title','Title:')}}
It needs to be
{!! Form::label('title','Title:') !!}
回答5:
You can do it in laravel 5.5 too.
Step 1: Install from Command: composer require "laravelcollective/html":"^5.5"
Step 2: After install you have to add providers and aliases in config/app.php file, so let' follow bellow file how to add.
Step 2.1:
<?php
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
Step 3: After added above providers, you have to check on your project.
Step 4: Done.
Thanks.
回答6:
it Simple use this one:
composer require laravelcollective/html
来源:https://stackoverflow.com/questions/46392542/laravelcollective-html-not-working-in-laravel-5-5