Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CLab's avatar
Level 3

Uninstalled package but get ServiceProvider Error on optimize

I removed the package superbalist/laravel-google-cloud-storagefrom from my application using

 composer remove superbalist/laravel-google-cloud-storage

as I want to replace it with the Spatie package (Laravel 9 support). Currently my application is Laravel 8 but want to upgrade to Laravel 9.

I also ran composer update and composer dump-autoload.

After removing this package, I run php artisan optimize and it works fine. However I use different env variables for production and when I run php artisan optimize --env=production It gives the following error:

   Error 

  Class "Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider" not found

  at C:\GCPProjects\glybrary-laravel\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:745
    741▕      * @return \Illuminate\Support\ServiceProvider
    742▕      */
    743▕     public function resolveProvider($provider)
    744▕     {
  ➜ 745▕         return new $provider($this);
    746▕     }
    747▕
    748▕     /**
    749▕      * Mark the given provider as registered.

Here is the log

[2022-06-23 20:43:50] laravel.ERROR: Class "Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider" not found {"exception":"[object] (Error(code: 0): Class \"Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider\" not found at C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:745)
[stacktrace]
#0 C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(679): Illuminate\Foundation\Application->resolveProvider('Superbalist\\Lar...')
#1 C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php(75): Illuminate\Foundation\Application->register('Superbalist\\Lar...')
#2 C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(659): Illuminate\Foundation\ProviderRepository->load(Array)
#3 C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#4 C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(237): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#5 C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith(Array)
#6 C:\projects\example\\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#7 C:\projects\example\\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 {main}
"} 

What I have tried so far:

  1. Cleared the bootstrap\cache directory
  2. Removed the provider from the config\app.php
  3. Removed the entire vendor directory and run composer update
  4. Tried running composer clear-cache
  5. Tried php artisan cache:clear and php artisan config:clear

Also weirdly this error comes only when using the production .env file.

0 likes
3 replies
tomopongrac's avatar

Did you try

php artisan cache:clear
php artisan config:clear
CLab's avatar
Level 3

Got the fix. It turns out in my production .env I was overwriting the APP_PACKAGES_CACHE to tmp for serverless and that was being saved even if I tried clearing the cache. To fix, simply go to the tmp folder or whatever folder you had set and remove the cached files from there.

Please or to participate in this conversation.