表单不是核心组件的一部分,因此您需要将其添加到 laravel。为此,您需要编辑 laravel 主目录中的 composer.json 文件。更改此行
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*"
},
至
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "5.2.*"
},
然后composer update
在您的终端中运行。它将添加所有包含表单的集合。
接下来,您必须将新提供者添加到 config/app.php 的提供者数组中。
你会在你的 app.php 中找到它
'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,
....................
需要添加行所以Collective\Html\HtmlServiceProvider::class,
将提供者更改为
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Collective\Html\HtmlServiceProvider::class, ....
最后一步是将两个类别名添加到 config/app.php 的 aliases 数组中
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,...
添加额外的两个类 FORM,HTML 那里
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,...
现在你可以在 laravel 中使用表单了。
参考:https ://laravelcollective.com/docs/5.2/html