php - Laravel 5.2 升级 - 找不到类 AuthServiceProvider

标签 php laravel exception laravel-5 upgrade

我目前正在花时间将我的项目从 Laravel 4.2 升级到 Laravel 5.2。

在经历了很多麻烦之后,我设法让 5.1 版本正常运行,所以我开始了 5.1 到 5.2 的过程,如官方文档中所述:https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0

第一步之后,我的 composer.json 看起来像这样:

"require": {
        "laravel/framework": "5.2.*",
        "illuminate/html": "5.*",
        "andywer/js-localization": "dev-laravel-5",
        "laracasts/flash" : "~1.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "symfony/dom-crawler": "~3.0",
        "symfony/css-selector": "~3.0"
    },
    "autoload": {
        "classmap": [
            "database",
            "app/Models",
            "app/Http/Controllers"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },

我还更新了 app.php 配置以删除提供程序部分中的 ArtisanServiceProvider 和 ControllerServiceProvider。

我的app.php 配置 如下所示:

/*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    | The service providers listed here will be automatically loaded on the
    | request to your application. Feel free to add your own services to
    | this array to grant expanded functionality to your applications.
    |
    */

    'providers' => array(

        /*
         * Laravel Framework Service Providers...
         */
        'Illuminate\Auth\AuthServiceProvider',
        'Illuminate\Broadcasting\BroadcastServiceProvider',
        'Illuminate\Bus\BusServiceProvider',
        'Illuminate\Cache\CacheServiceProvider',
        'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
        'Illuminate\Cookie\CookieServiceProvider',
        'Illuminate\Database\DatabaseServiceProvider',
        'Illuminate\Encryption\EncryptionServiceProvider',
        'Illuminate\Filesystem\FilesystemServiceProvider',
        'Illuminate\Foundation\Providers\FoundationServiceProvider',
        'Illuminate\Hashing\HashServiceProvider',
        'Illuminate\Mail\MailServiceProvider',
        'Illuminate\Pagination\PaginationServiceProvider',
        'Illuminate\Pipeline\PipelineServiceProvider',
        'Illuminate\Queue\QueueServiceProvider',
        'Illuminate\Redis\RedisServiceProvider',
        'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
        'Illuminate\Session\SessionServiceProvider',
        'Illuminate\Translation\TranslationServiceProvider',
        'Illuminate\Validation\ValidationServiceProvider',
        'Illuminate\View\ViewServiceProvider',
        /*
         * Application Service Providers...
         */
        'App\Providers\AppServiceProvider',
        'App\Providers\AuthServiceProvider',
        'App\Providers\EventServiceProvider',
        'App\Providers\RouteServiceProvider',

        // LIBS TIERCE
        JsLocalization\JsLocalizationServiceProvider::class,
        'Laracasts\Flash\FlashServiceProvider',

    ),

    /*
    |--------------------------------------------------------------------------
    | Service Provider Manifest
    |--------------------------------------------------------------------------
    |
    | The service provider manifest is used by Laravel to lazy load service
    | providers which are not needed for each request, as well to keep a
    | list of all of the services. Here, you may set its storage spot.
    |
    */

    'manifest' => storage_path().'/meta',

    /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => array(

        'App'       => Illuminate\Support\Facades\App::class,
        'Artisan'   => Illuminate\Support\Facades\Artisan::class,
        'Auth'      => Illuminate\Support\Facades\Auth::class,
        'Blade'     => Illuminate\Support\Facades\Blade::class,
        'Cache'     => Illuminate\Support\Facades\Cache::class,
        'Config'    => Illuminate\Support\Facades\Config::class,
        'Cookie'    => Illuminate\Support\Facades\Cookie::class,
        'Crypt'     => Illuminate\Support\Facades\Crypt::class,
        'DB'        => Illuminate\Support\Facades\DB::class,
        'Eloquent'  => Illuminate\Database\Eloquent\Model::class,
        'Event'     => Illuminate\Support\Facades\Event::class,
        'File'      => Illuminate\Support\Facades\File::class,
        'Gate'      => Illuminate\Support\Facades\Gate::class,
        'Hash'      => Illuminate\Support\Facades\Hash::class,
        'Lang'      => Illuminate\Support\Facades\Lang::class,
        'Log'       => Illuminate\Support\Facades\Log::class,
        'Mail'      => Illuminate\Support\Facades\Mail::class,
        'Password'  => Illuminate\Support\Facades\Password::class,
        'Queue'     => Illuminate\Support\Facades\Queue::class,
        'Redirect'  => Illuminate\Support\Facades\Redirect::class,
        'Redis'     => Illuminate\Support\Facades\Redis::class,
        'Request'   => Illuminate\Support\Facades\Request::class,
        'Response'  => Illuminate\Support\Facades\Response::class,
        'Route'     => Illuminate\Support\Facades\Route::class,
        'Schema'    => Illuminate\Support\Facades\Schema::class,
        'Session'   => Illuminate\Support\Facades\Session::class,
        'Storage'   => Illuminate\Support\Facades\Storage::class,
        'URL'       => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View'      => Illuminate\Support\Facades\View::class,
        'Form'      => 'Illuminate\Html\FormFacade',
        'HTML'      => 'Illuminate\Html\HtmlFacade',

        // FAÇADES TIERCES
        'Flash'             => 'Laracasts\Flash\Flash'

    ),

当然,我在 bootstrap/cache 中清除了配置缓存,并尽我所能让它工作,但每次运行 composer update 时,我都会收到此错误现在:

> php artisan clear-compiled


  [Symfony\Component\Debug\Exception\FatalErrorException]
  Class 'App\Providers\AuthServiceProvider' not found


Script php artisan clear-compiled handling the post-update-cmd event returned with an error



  [RuntimeException]
  Error Output:

比这更糟糕的是,我无法运行任何 artisan 命令或我的应用程序页面。每当我在这个项目中运行一些 php 时,我总是收到这个错误!

这是我尝试过的一些 Action :

  • 删除所有缓存,包括config cache和services.json(由于artisan命令出错,无法重新生成)
  • 删除 vendor 文件夹并重新运行 composer update
  • 从 app.php 配置中删除 'Illuminate\Auth\AuthServiceProvider',

这些都不起作用,我的新想法也用完了。 我已经阅读并重新阅读了官方文档的升级指南,似乎没有任何内容与此问题相关...

我仍在为 Laravel 中的所有 psr-4/命名空间问题而苦苦挣扎,我感觉它可能是由类似的原因引起的,但无法弄清楚到底是什么......

最佳答案

您是否在/app/Providers 文件夹中放置了此服务提供商 App\Providers\AuthServiceProvider

如果不从这里复制并修复命名空间

https://github.com/laravel/laravel/blob/master/app/Providers/AuthServiceProvider.php

关于php - Laravel 5.2 升级 - 找不到类 AuthServiceProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34636772/

相关文章:

未捕获 Python 语法错误

javascript - SQL请求重复

php - 如何在 laravel 中使用 pangination 和 sortByDesc 功能?

php - 查询需要很长时间来执行 laravel

c# - C#中的异常处理 : Multple Try/Catches vs. 一

java - 如何在不更改代码的情况下从编译的 jar 中检索完整的异常消息?

php - SilverStripe 3.1 - 从前端创建和发布页面

php - 在mysql中插入双引号并打印出来,不带反斜杠

php - 将 xml feed 写入数据库,如何安全删除旧记录并更新新记录?

Laravel 5.5 队列调度不起作用