Reputation:
My laravel version 5.7.8 I am trying to install the last Laravel Collective, using this code:
composer require "laravelcollective/html":"^5.4.0"
But it doesn't work, why?
This is my code in contact view page:
{!! Form::open(['url' => 'contact/submit']) !!}
<div class="form-group">
{{Form::label('name', 'Name')}}
{{Form::label('name', 'Enter your name')}}
</div>
<div class="form-group">
{{Form::label('email', 'E-Mail Address')}}
{{Form::label('email', 'example [email protected]')}}
</div>
{!! Form::close() !!}
Upvotes: 3
Views: 6666
Reputation: 1104
If you use LaravelCollection version 5.7 or newer, the only thing you need to do is run
composer require laravelcollective/html
and you are good to go.
Upvotes: 0
Reputation: 1
i solve this : 1-
composer require laravelcollective/html
"i find it in packagist" 2-IN LARAVEL PROJECT
CONFIG/app.php:
'providers' => [
Collective\Html\HtmlServiceProvider::class,
],
"i add line of code at the end of providers and don't toch anything else" 3-IN LARAVEL PROJECT CONFIG/app.php:
'aliases' => [
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
],
4-on cmd or gitbash
composer update
"this will use internet resource!" 5- in cmd or git bash
php artisan serve
6- check form on web browser
Upvotes: 0
Reputation: 10091
There is no problem in your code, I assume that you have forgotten any step to during installation time
I will start with the initial stage how to use laravelcollective/html package
Begin by installing this package through Composer. Edit your project's composer.json
file to require laravelcollective/html
"require": {
"laravelcollective/html": "*"
}
Note: This will download the latest version of the laravelcollective/html package
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,
// ...
],
add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
Now put your code in the view file and check in the browser no longer will get error
Upvotes: 4
Reputation: 518
If you are running Laravel in the latest version, which is 5.7.*, it is possible the laravelcollective/html package is not up to date. Therefor you could check out the latest version, which is 5.7.1.
Reference: Packagist laravel/collectivehtml
If that doesn't help you have a look at your providers under config/app.php You need to got the following entry into your providers array
'Collective\Html\HtmlServiceProvider',
so the full array looks like
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
/*
* Collective Providers
*/
'Collective\Html\HtmlServiceProvider', //Your Provider here
/*
* Third Party Providers
*/
],
Next step would be to check if the aliases for the collective are set up correctly in the same file (config/app.php)
'aliases' => [
// ...
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
// ...
],
Hope this helps you out!
Upvotes: 0