May Sale! All accounts are 40% off this week.

audunru's avatar

Clear cache before deploy?

I recently replaced a composer package with another (laravelba/laravel-js-routes to aaronlord/laroute). Removed the old one with composer remove.

On deploy I get this error.

@php artisan package:discover

In ProviderRepository.php line 208:
                                                                              
  Class 'LaravelBA\LaravelJsRoutes\LaravelJsRoutesServiceProvider' not found  
                                                                              

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I've encountered it before, and clearing bootstrap/cache and redploying fixes it. Which leads me to believe clearing/removing the cache should be part of my deploy script. Does anyone know exactly what needs to be cleared/deleted, and if so, is there a artisan command to achieve this?

Here's my deploy script, maybe there's something there I should fix.

cd /home/forge/feedleback.com
php artisan down --message='Feedleback is being updated' --retry=180
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force
php artisan clear-compiled
php artisan config:cache
php artisan route:cache
php artisan cdn:push
php artisan queue:restart
php artisan up
php artisan opcache:clear
0 likes
5 replies
Cronix's avatar

Have you tried composer dump-autoload? after removing/adding packages?

audunru's avatar

I think perhaps that's where it fails. Included some more lines from the failed deployment log:

  - Installing axn/laravel-laroute (1.2.0): Downloading (connecting...)                           Downloading (0%)                                      Downloading (30%)                 Downloading (60%)                 Downloading (90%)                 Downloading (100%)
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In ProviderRepository.php line 208:
                                                                              
  Class 'LaravelBA\LaravelJsRoutes\LaravelJsRoutesServiceProvider' not found  
                                                                              

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
Helmchen's avatar

I think what's failing here is the auto-discover feature (just a script referenced in composer.json) of the laravel packages.

You could disable these with:

composer install --no-scripts

clear everything you need to and run the autodiscover manually

php artisan clear-compiled
php artisan package:discover

maybe give that a try, even if exactly that should already be done:

"post-autoload-dump": [
    "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
    "@php artisan package:discover"
]
audunru's avatar

Thanks, I will try on next deploy and report back.

Please or to participate in this conversation.