2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【PHP/Laravel】Class 'Collective\Html\HtmlServiceProvider' not found への対処法

Last updated at Posted at 2020-08-11

#はじめに
Laravelでアプリ開発をしております。
環境構築が完了し、Formを実装した際にエラーが発生。
備忘のために記録しております。
同じような方の助けになれば幸いです。

#開発環境
・MacOS:10.15.6 (Catalina)
・PHP7.3.20
・Laravel6.18.35

#対処法
###①プロジェクト直下の「composer.json」に「"laravelcollective/html": "^6.0"」を追記
※これでもエラーが起きる場合はLaravelのバージョンとlaravelcollective/htmlのバージョンを合わせる(ex. Laravel5.8なら、laravelcollective/htmlの5.8)。

composer.json
 "require": {
        "php": "^7.2",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "^6.2",
        "laravel/tinker": "^2.0" ,
        "laravelcollective/html": "^6.0"
    },

###②ターミナルで「composer update」を実行

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 3 updates, 0 removals
  - Updating egulias/email-validator (2.1.18 => 2.1.19): Downloading (100%)       - Installing league/mime-type-detection (1.4.0): Downloading (100%)         
  - Updating league/flysystem (1.0.70 => 1.1.0): Downloading (100%)         
  - Updating nikic/php-parser (v4.7.0 => v4.8.0): Downloading (100%)         
  - Installing laravelcollective/html (v6.1.2): Downloading (100%)         
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: laravelcollective/html
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
40 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

###③「config/app.php」への下記の追記
※Laravel5.5以上はPackage Auto Discoveryが入っているため不要。

config/app.php
   'providers' => [
        Collective\Html\HtmlServiceProvider::class,
    ],

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

以上となります。

以下、参考にさせていただいたサイトも掲載させていただきます。
ご参考にしていただければ。

#参考文献
Laravelで「Formクラスが無い」とエラーが出た時の対処法
【Laravel】Formファサード(laravelcollective/html)をインストールする

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?