I have a particular project that consistently throws a bunch of identical errors every time I deploy my project. I sync my project using rsync using the -a flag and --exclude-from to which I pass a file where the vendor folder is listed (among other stuff).
The error that occurs is the following:
production.ERROR: Class "Barryvdh\Debugbar\ServiceProvider" not found
I'm suspecting it has something to do with the autoloading but I do not know enough about how that works in practice to debug it.
So, here's the weird parts:
If I remove that package (barryvdh/laravel-debugbar), the error persists but with another package.
I have another project with the same setup, but different packages (but both have barryvdh/laravel-debugbar). This project does not yield any errors on synchronization.
The error doesn't seem to affect the web app at all.
After deployment/synchronization I run composer install --no-dev -optimize-autoloader.
The Laravel Debugbar should not be installed in production, so it is probably because you use composer install with --no-dev flag on that environment, and since you are moving the files with rsync probably some of the cache is being synchronized as well, which should not be.
A composer dump-autoload after installing should fix the issue.
The problem was because the server was running queue:listen as opposed to queue:work. I guess queue:listen relentlessly poked the codebase and revealed that rsync leaves holes when running. It seemed easier when I did it, but as always shortcuts like these ends up biting oneself in the ass.
To make sure that all jobs are up to date, I simply run php artisan queue:restart after deployment.