Laravel 5.2 - Class' Illuminate \ Html \ HtmlServiceProvider'未找到

时间:2017-02-17 15:27:33

标签: php laravel-5.2 composer-php

我最近决定从laravel 5.1升级到5.2。我的composer.json文件如下:

Hdbdh

我的app.php文件中的providers数组如下:

{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": ["framework", "laravel"],
  "license": "MIT",
  "type": "project",
  "require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "laracasts/flash": "dev-master",
    "laravelcollective/html": "5.2.0",
    "intervention/image": "^2.3",
    "cviebrock/image-validator": "^2.0"

  },
  "require-dev": {
      "fzaninotto/faker": "~1.4",
      "mockery/mockery": "0.9.*",
      "phpunit/phpunit": "~4.0",
      "phpspec/phpspec": "~2.1",
      "symfony/dom-crawler": "~3.0",
      "symfony/css-selector": "~3.0"
 },
 "autoload": {
    "classmap": [
        "database"
    ],
    "files": ["app/Http/helpers.php"],
    "psr-4": {
        "App\\": "app/"
    }
 },
 "autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
 },
 "scripts": {
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
 },
 "config": {
    "preferred-install": "dist"
 },
 "minimum-stability": "dev",
 "prefer-stable": true
}

我做'providers' => [ Illuminate\Auth\AuthServiceProvider::class, // some more... Illuminate\View\ViewServiceProvider::class, Collective\Html\HtmlServiceProvider::class, Laracasts\Flash\FlashServiceProvider::class, Intervention\Image\ImageServiceProvider::class, Cviebrock\ImageValidator\ImageValidatorServiceProvider::class, ], 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, // some more... 'Form' => Collective\Html\FormFacade::class, 'Html' => Collective\Html\HtmlFacade::class, 'Image' => Intervention\Image\Facades\Image::class, ], 并收到以下错误:

composer update

尝试运行> C:\ProgramData\ComposerSetup\bin\composer.bat update Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files > php artisan clear-compiled [Symfony\Component\Debug\Exception\FatalErrorException] Class 'Illuminate\Html\HtmlServiceProvider' not found Script php artisan clear-compiled handling the post-update-cmd event returned with error code 255 时出现同样的错误。我已经尝试了所有常用的内容,例如php artisan serve等。

为什么会发生这种情况并解决了什么?

2 个答案:

答案 0 :(得分:0)

取自Class 'Illuminate\Html\HtmlServiceProvider' not found Laravel 5

首先将此行添加到composer.json

"laravelcollective/html": "5.2.0"

然后执行composer update等待更新完成,然后打开 config / app.php 添加此内容:

Collective\Html\HtmlServiceProvider::class 

到providers数组,这个:

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

到别名数组,并确保何时在刀片中使用Html或在小写的“Html”而不是HTML中使用它。

请注意,正如此答案所说,首先添加composer.json行,然后进行更新,然后将行添加到app.php。您无法将这两个步骤结合起来并使其有效。

答案 1 :(得分:0)

管理修复。我在整个项目中进行了搜索,看看它是否仍在任何地方被引用。瞧,它仍然在macroserviceprovider中引用,所以我改为使用use Collective\Html\HtmlServiceProvider;代替。