Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
216 views
in Technique[技术] by (71.8m points)

php - Laravel 5 Class 'form' not found

I have added "illuminate/html": "5.*" to composer.json and ran "composer update".

  - Installing illuminate/html (v5.0.0)
    Loading from cache

I ran this command in the root of the website. I modified the composer.json file in /root/.composer... and in the root of the project and neither have made a difference.

This downloaded the class and it seemed to install. I have added the following to file config/app.php.

    'IlluminateHtmlHtmlServiceProvider',

    'Form'      => 'IlluminateHtmlFormFacade',
    'Html'      => 'IlluminateHtmlHtmlFacade',

I think I have an idea what is wrong, but I don’t know how to fix it. My install is in '/var/www/website'. I have checked the file path and the Html folder does not exist.

"/var/www/website/vendor/laravel/framework/src/Illuminate/Html"

I was able to find the class files, but in a different directory.

"/var/www/website/vendor/illuminate/html"

I manually copied the files over to the main Laravel illuminate/html folder, but this hasn't worked either.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Form isn't included in laravel 5.0 as it was on 4.0, steps to include it:

Begin by installing laravelcollective/html package through Composer. Edit your project's composer.json file to require:

"require": {
    "laravelcollective/html": "~5.0"
}

Next, update composer from the Terminal:

composer update

Next, add your new provider to the providers array of config/app.php:

'providers' => [
  // ...
  'CollectiveHtmlHtmlServiceProvider',
  // ...
],

Finally, add two class aliases to the aliases array of config/app.php:

'aliases' => [
// ...
  'Form' => 'CollectiveHtmlFormFacade',
  'Html' => 'CollectiveHtmlHtmlFacade',
// ...
],

At this point, Form should be working

Source


Update Laravel 5.8 (2019-04-05):

In Laravel 5.8, the providers in the config/app.php can be declared as:

CollectiveHtmlHtmlServiceProvider::class,

instead of:

'CollectiveHtmlHtmlServiceProvider',

This notation is the same for the aliases.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...