找不到 Laravel 5.4 类“表单”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43207428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.4 Class 'form' not found
提问by hemant
I'm facing problem 'Class 'form' not found'I'm currently using laravel 5.4. I already have tried maximum efforts to solve.
我正面临问题“找不到类‘表单’”我目前使用的是 laravel 5.4。我已经尽力解决了。
Thanks
谢谢
Error is : Whoops, looks like something went wrong.
错误是:哎呀,好像出了点问题。
1/1
1/1
FatalErrorException in d0b19e04e5a1f8a5507d8ca427362b23807103ca.php line 23: Class 'Form' not found in d0b19e04e5a1f8a5507d8ca427362b23807103ca.php line 23
d0b19e04e5a1f8a5507d8ca427362b23807103ca.php 第 23 行中的 FatalErrorException:在 d0b19e04e5a1f8a5507d8ca427362b23807103ca 行中找不到“表单”类
Here is my Comp
这是我的比较
{
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4"
},
}
I run the composer update command.
我运行 composer update 命令。
Here is my 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,
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\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
'Collective\Html\HtmlServiceProvider',
/*
* Package Service Providers...
*/
Laravel\Tinker\TinkerServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'FORM' => 'Collective\Html\FormFacade',
'HTML' => 'Collective\Html\HtmlFacade',
],
];
using form in formupload.blade.php
在 formupload.blade.php 中使用表单
@if(isset($success))
<div class="alert alert-success"> {{$success}} </div>
@endif
{!! Form::open(['action'=>'ImageController@store', 'files'=>true]) !!}
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', null, ['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('description', 'Description:') !!}
{!! Form::textarea('description', null, ['class'=>'form-control', 'rows'=>5] ) !!}
</div>
<div class="form-group">
{!! Form::label('image', 'Choose an image') !!}
{!! Form::file('image') !!}
</div>
<div class="form-group">
{!! Form::submit('Save', array( 'class'=>'btn btn-danger form-control' )) !!}
</div>
{!! Form::close() !!}
<div class="alert-warning">
@foreach( $errors->all() as $error )
<br> {{ $error }}
@endforeach
</div>
</div>
回答by Hitarthi Panchal
Put this in composer.json
把它放在 composer.json 中
"require": {
"laravelcollective/html": "^5.4"
},
and Run
并运行
composer update
in command afterwards
之后指挥
Or
或者
composer require laravelcollective/html
Then add this in your config/app.php in providers section array
然后将其添加到您的 config/app.php 中的 providers 部分数组中
Collective\Html\HtmlServiceProvider::class,
After that add two class aliases in the config/app.php in aliases array
之后在 config/app.php 的 aliases 数组中添加两个类别名
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
回答by Shogunivar
Looks like you set the alias for your Form Class to "FORM" here in your app.php:
看起来您在 app.php 中将表单类的别名设置为“FORM”:
'FORM' => 'Collective\Html\FormFacade',
'FORM' => 'Collective\Html\FormFacade',
Try changing that to Form
like so:
尝试将其更改为Form
这样:
'Form' => 'Collective\Html\FormFacade',
'Form' => 'Collective\Html\FormFacade',
then it should work
那么它应该工作
回答by Nadeem Qasmi
run command
运行命令
composer require laravelcollective/html
when the composer update the require html laravel collective
then add these two line into config/app.php into the section of
'aliases' => [ ],
当作曲家更新 require html laravel 集合时,将这两行添加到 config/app.php 中的
“别名”=> [] 部分,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
then add the line into config/app.php
'providers' => [ ],and save the file
然后将这一行添加到 config/app.php
'providers' => [] 中,并保存文件
Collective\Html\HtmlServiceProvider::class,
回答by anoja madusanka
Run the command
运行命令
composer require laravelcollective/html
add these two lines into config/app.php into the section of
'aliases' => [ ],
将这两行添加到 config/app.php 的部分
'aliases' => [ ],
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
add the line into config/app.php
'providers' => [ ]
, and save the file
将该行添加到 config/app.php 中
'providers' => [ ]
,并保存文件
Collective\Html\HtmlServiceProvider::class,
this also works for 6.X
这也适用于 6.X
回答by Parveen Chauhan
class aliases in the config/app.php
中的类别名 config/app.php
'Form' => 'Collective\Html\FormFacade',
this is working for me
这对我有用