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

JimmyV's avatar
Level 16

bootstrap/cache/services.php file being deleted after certain php artisan commands

I have a very frustrating problem and I have at a loss for what is causing it.

Using Laravel 5.7, when I run a php artisan make:migration command, or make a model with a migration (make:model -m), it runs fine once; the migration is created. But after that I am unable to run any further php artisan commands. The same issue also arises when making a seeder. Every time I try I get:

In Container.php line 779:

Class view does not exist

I have noticed that upon running the command, the bootstrap\cache\services.php file is being removed. Using a backup to replace this file in the directory fixes the problem, allowing me to run php artisan commands again. But the moment I make a migration or a seeder, the file is removed again and I encounter the same error.

  • I have tried a composer dump-autoload. If the services.php file is in the directory, it gets removed again and I am shown the error.
  • I have tried composer update and composer install (including after removing the vendor folder)
  • I have tried php artisan config:cache and php artisan config:clear
  • I have checked my .env file for spaces not contained within quotations.
  • I have checked that 'Illuminate\View\ViewServiceProvider::class,' is in my config\app.php file under 'providers'.
  • I have done a complete reinstall of composer, node.js and laravel. This initially seemed to fix the problem, but I ran a migration of the migration tables I had already created just to check they were formed correctly. After that, the next migration I tried to make caused the services.php file to be removed and the error to arise once again.

Any help will be greatly appreciated. I'm sure you can appreciate how frustrating this must be.

0 likes
6 replies
munazzil's avatar

Check with below command

php artisan view:clear
php artisan cache:clear
1 like
JimmyV's avatar
Level 16

I've just given that a go, but it hasn't fixed the issue. :/

JimmyV's avatar
Level 16

No, unfortunately that causes the same problem. Removes both services.php and packages.php file, and the next time I try to run any 'php artisan' command, the packages.php file is rebuilt, but the services.php file is not, and it fails again.

adammench's avatar

If all else fails, I run rm -rf vendor && composer install to solve this issue (my problem was that an old class kept getting added to bootstrap/cache/packages.php rendering the artisan CLI useless.

Please or to participate in this conversation.