无法在 Laravel 5.1 中安装 Laravelcollective/HTML

Can't install Laravelcollective/HTML in Laravel 5.1

我在 Laravel 5.1 Install laravelcollective/html document 中安装 Laravelcollective/HTML 时遇到问题。 首先,我通过 Composer 安装:

composer require illuminate/html

消息: Using version ~5.0 for illuminate/html ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev)

但它是 5.0 版,所以删除它。

composer remove illuminate/html

并安装5.1版本

"require": {
    "laravelcollective/html": "5.1.*"
}

接下来,从终端更新 Composer:

composer update

接下来,将您的新提供商添加到 config/app 的提供商数组中。php:

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

最后,在config/app的别名数组中添加两个class别名。php:

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

并且消息错误:

 FatalErrorException in ProviderRepository.php line 146:
 Class 'Collective\Html\HtmlServiceProvider' not found

在我 运行 作曲家更新之前,我以某种方式添加到 config/app.php 下面,因此它产生了与您遇到的相同的错误。

在作曲家更新之前不要添加以下内容。

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

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

我找到了解决办法。您可以 运行 composer 下面的这个命令。它将安装 laravelcollective/html

composer require laravelcollective/html

我的问题是我有一个缓存的配置文件,我无法重新缓存它,因为它是通过 artisan 缓存的,而 artisan 抛出了错误。

解决方案:

已删除:

bootstrap/cache/config.php

composer update