Laravel 5.2: Undefined class form

女生的网名这么多〃 提交于 2019-12-06 15:17:47

问题


I have a problem with using Form command in a Composer + Laravel 5.2 project with PhpStorm as IDE.

I'm using Laravel Collective 5.2. in my composer.json, so it should work. (sadly, it's not which is the reason I'm here...)

The providers:

Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,

my aliases.

'Form'      => Collective\Html\FormFacade::class,
'Html'      => Collective\Html\HtmlFacade::class,

The problem: It's returned as a undefined class when I'm using {!! Form::close() !!} or any form command in my blade.php.

Did I misunderstood something when I installed it in the project? What do I need to configure in order for this to work?

And yes, I have looking around on forums. The answers didn't help because they were for Laravel 4 or Laravel 5.1. :S


回答1:


Actually i'm not even mad that's amazing because I found a solution to my problem... just around 5 min after I post my question... And I spend around 2 hours to find a solution...

All I did was:

php artisan clear-compiled
php artisan ide-helper:generate
php artisan optimize

and reload the blade.php.

I have no idea why, but it works now. It seems I forgot to run the above commands after I got Laravel Collective 5.2 in the project. This could be the reason that form command didn't work. .___.;;

I hope someone could use this information for their own project.




回答2:


You can get full solution about form builder in Laravel 5.2.

Run command prompt and execute

  1. composer require laravelcollective/html
  2. Open config/app.php In providers array add Collective\Html\HtmlServiceProvider::class and in aliases array add
‘Form’ => Collective\Html\FormFacade::class,
‘Html’ => Collective\Html\HtmlFacade::class

For more details, See there http://laraveldeveloper.me/form-in-laravel-5-2



来源:https://stackoverflow.com/questions/34806513/laravel-5-2-undefined-class-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!