Here is the message I have when I access my site:
Fatal error: Uncaught Error: Call to undefined method ComposerAutoloaderInitd7a72f88a86cf25d5563498a7179620e::getLoader()
in /home/vagrant/code/vendor/autoload.php:7
Stack trace: #0 /home/vagrant/code/public/index.php(34): require() #1 {main}
thrown in /home/vagrant/code/vendor/autoload.php on line 7
I am using
- popOS
- PHP 7.4.18
- Apache 2.4.41
- Vagrant 2.2.9
- Laravel 8.40.0
I have found many SO questions about it, but nothing worked so far. I tried:
- checked that the generated files are present and run (
dd
‘d into it) composer dump-autoload
rm -rf vendor
,composer install
- changed PHP version (8.0.x, 7.4.18)
- deleted all caches (composer and Laravel)
If you have any idea on what’s going on… Thanks!
EDIT
I destroyed the VM. Before anything else I accessed the site and had the message saying that the session table was not found. Good. Then I ran a php artisan migrate:fresh --seed
and here is the message I got:
Fatal error: Uncaught Error: Call to undefined method Swift::registerAutoload() in /home/vagrant/code/vendor/swiftmailer/swiftmailer/lib/swift_required.php:13 Stack trace: #0 /home/vagrant/code/vendor/composer/autoload_real.php(71): require() #1 /home/vagrant/code/vendor/composer/autoload_real.php(61): composerRequiree92ff6905f8cf8863d20126d313557d0() #2 /home/vagrant/code/vendor/autoload.php(7): ComposerAutoloaderInite92ff6905f8cf8863d20126d313557d0::getLoader() #3 /home/vagrant/code/public/index.php(34): require('/home/vagrant/c...') #4 {main} thrown in /home/vagrant/code/vendor/swiftmailer/swiftmailer/lib/swift_required.php on line 13
It does not reappear after a refresh, but the first message popped again.
2
Answers
After days on this issue I decided to switch from Homestead to Docker, though I've always worked with the first, and it worked well before I reinstalled my computer.
Now everything works well. This is not THE solution I was expecting, but I can now start to work again.
Try disabling opcache
In Ubuntu you can do this by adding
opcache.enable=0
to
/etc/php/7.4/fpm/conf.d/10-opcache.ini
Or for whatever PHP version you are running
Edit: you will also need to restart PHP with
sudo service php7.4-fpm restart