Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.2 upgrade - class AuthServiceProvider not found

I'm currently spending time to upgrade my project from Laravel 4.2 to Laravel 5.2.

After lots of troubles I managed to get a 5.1 version running correctly so I started the 5.1 to 5.2 procedure as described in the official docs: https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0

After the first step, my composer.json looks like this:

"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"
        ]
    },

I also updated the app.php config to delete ArtisanServiceProvider and ControllerServiceProvider in the providers section.

My app.php config looks like this:

/*
    |--------------------------------------------------------------------------
    | 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'

    ),

Of course, I cleared the config cache in bootstrap/cache and I tried everything I could to make it work but every time I run composer update I get this error now:

> 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:

worse than this, I can't run any artisan command or pages of my application. I keep getting this error any time I run some php in this project !

This is some moves I tried:

  • Delete all caches including config cache and services.json (impossible to regenerate them because of the error in artisan commands)
  • delete the vendor folder and re-run composer update
  • delete the 'Illuminate\Auth\AuthServiceProvider', line from app.php config

None of this worked and I'm running out of fresh ideas. I have read and re-read the upgrade guide of the official docs and nothing seems to be related to this issue...

I'm still struggling with all that psr-4 / namespace thing in Laravel and I sense it can be caused something like that but can't figure out what exactly...

like image 825
YannPl Avatar asked Jan 06 '16 15:01

YannPl


2 Answers

Do you have this service provider in place App\Providers\AuthServiceProvider in the /app/Providers folder

If not copy it from here and fix the namespace

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

like image 86
Simon Bennett Avatar answered Oct 21 '22 20:10

Simon Bennett


update

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

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

I think those are causing your issues, try running it without those and check if these packages are 5.2 compatible. I also think that the Html component have been removed from the 5.* they should be maintained by collective so what you would need to do is to add the following rather than the Illuminate

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

Visit Laravel Collectives for more info

like image 23
Sari Yono Avatar answered Oct 21 '22 21:10

Sari Yono