当前位置: 首页 > 知识库问答 >
问题:

Laravel 5.2升级-未找到类AuthServiceProvider

凌征
2023-03-14

我目前正在花时间将我的项目从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和ControlllerServiceProvider。

我的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时,我总是会遇到这个错误!

以下是我尝试过的一些动作:

  • 删除所有缓存,包括配置缓存和服务。json(由于artisan命令中的错误,无法重新生成)
  • 删除供应商文件夹并重新运行composer update
  • 从应用程序中删除“Illumb\Auth\AuthServiceProvider”行。php配置

这些都不管用,我的新想法也快用完了。我已经阅读并重读了官方文件的升级指南,似乎与此问题无关。。。

我仍然在与Laravel中的所有psr-4/命名空间的事情作斗争,我感觉它可能是由这样的事情引起的,但不知道到底是什么...

共有3个答案

孟晨朗
2023-03-14

尝试将下面的字符串放在引号内,如下所示,然后重试

'JsLocalization\JsLocalizationServiceProvider::class',
令狐献
2023-03-14

更新

    'Form'      => 'Illuminate\Html\FormFacade',
    'HTML'      => 'Illuminate\Html\HtmlFacade',

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

我认为这些都是造成您的问题的原因,请尝试在没有这些问题的情况下运行它,并检查这些软件包是否与5.2兼容。我还认为Html组件已经从5中删除。*它们应该由集体维护,因此您需要做的是添加以下内容,而不是

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

更多信息,请访问Laravel Collectives

符畅
2023-03-14

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

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

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

 类似资料:
  • 我将IntelliJ Idea从12.0.4升级到了12.10。 现在我的Android项目中的所有模块都给出了错误: 错误:未找到默认activity 我回到12.0.4,一切又正常了。 有什么想法吗?我认为这可能是一个问题与一个缺失的插件。由于插件没有安装,它无法找到默认的activity。另一件事可能是本地配置,但我怀疑。我删除了配置文件夹来验证,但这并没有改变任何东西。

  • 当我尝试启动应用程序时,在将Spring Boot从2.1.5升级到2.2.2之后,我收到了这个异常消息。 当我刚刚升级到SpringBoot2.2.1时,这个异常不会发生。 添加依赖项后: 它适用于2.2.2。 所以我的问题是,为什么在这次Spring Boot升级之后突然需要手动添加依赖项。

  • 我用Play2.0创建了一个应用程序。我实现了scribe-java库来使用一些OAuth服务。直到今天,一切都很好,但当我升级jdk并重新启动服务器时,我不能使用scribe-java库。它似乎在sun.security包中使用了和类,但找不到。 “java-version”返回: 播放2.0 StackTrace:

  • 我已将Spring启动从1.2.8更新到1.3.4。 然后我得到一个FileNotFoundExceptionlog4j.properties.早些时候它与旧的Spring启动版本一起工作。 我有log4j。应用程序所在资源的同一文件夹下的属性。属性文件驻留。正在应用中。我的财产档案如下, 登录中。配置=log4j。属性 在我下面的pom文件中,

  • 我用Android Studio为Unity做了一个jar插件。我的插件使用。但找不到该类。Unity的控制台向我显示了以下错误:

  • 我不知道如何处理以下错误,我已经搜索了网络,但没有找到任何东西: 以及: 我在gradle应用程序中的依赖项: