phplaravelcomposer-phplaravel-spark

laravel-spark-google2fa Provider class not found after Spark update to v9.0


I recently updated a Laravel/Spark web application to the latest version of Spark (v9.*) via composer. Another package I use is Laravel-Spark-Google2FA which I also updated from v1.* to v2.*.

Setup:

The laravel-spark-google2fa package has a Laravel service provider class that resides in /project-root/laravel/spark/src/Providers/Google2FAServiceProvider.php

In Laravel we specify this in /project-root/laravel/config/app.php with the following line in the providers array:

Laravel\Spark\Providers\Google2FAServiceProvider::class,

In composer.json we have:

"require": {
      ...
    "doctrine/dbal": "^2.5",
    "laravel/framework": "^6.0.0",
    "eusebiu/laravel-spark-google2fa": "^2.0.0",
    "laravel/cashier": "^10.0.0",
    "laravel/spark-aurelius": "^9.0.0",
    "laravel/tinker": "^1.0.0",
    "laravelcollective/html": "^6.0.0",
    "webpatser/laravel-uuid": "2.*"
},
"autoload": {
      ...
    "psr-4": {
        "App\\": "app/"
    }
},
...

Note: aside from the higher version numbers you see above in the require section, this has been the setup for a long time with the web application running successfully during that time.

Error:

Since we upgraded laravel/spark to laravel/spark-aurelius: ^9.0.0 we've run into one error which prevents the application from running:

In ProviderRepository.php line 208:

  Class 'Laravel\Spark\Providers\Google2FAServiceProvider' not found  

Failed attempts

We have tried the following to fix this, none of which have worked:

In all of the above cases the error remains, preventing the application from running.

The laravel-spark-google2fa package may be recently abandoned. I opened an issue there and haven't heard a reply. Laravel/Spark support has not suggested a solution. So I am posting here as a last resort before getting rid of this package and refactoring my code to use a different one.


Solution

  • I was unaware of the bootstrap cache. The bootstrap cache file contained a reference to the Google2FAServiceProvider service provider class which after various package updates and what not was no longer present.

    Running commands like php artisan config:clear, php artisan cache:clear, and composer dump-autoload did not clear this cache. In the end, I simply removed the offending file:

    filename: services.php

    location: /laravel/bootstrap/cache/services.php

    config.php, in the same location, can also contain such references.

    Note: I used the find feature in VSCode to look for references to this service provider and it did not find this one because the bootstrap cache is gitignored.