I have a server running on apache2 with some virtual hosts and I want to deploy a Symfony3 application on it. However, I cannot deploy it correctly to the production environment, it works perfectly on development environment. Whenever I do execute
sudo composer install --no-dev --optimize-autoloader
I get the error: PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /my/path/app/AppKernel.php on line 25 Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command: PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle'not found in /my/path/app/AppKernel.php on line 25.
After getting this error I went to read the documentation again and it said that I need to export this the Symfony environment to production. So I did that:
export SYMFONY_ENV=prod
After that I executed the composer install
command again but, same results.
Some people on Stackoverflow (and other sources) said that I need to clear my cache by executing
sudo bin/console cache:clear --env=prod
So I did that but same results. Anyone any idea?
Other sulutions tried: Actually it works great whenever I execute the command this way:
sudo SYMFONY_ENV=prod composer install --no-dev --optimize-autoloader
However, whenever everything was installed correctly, I went to try to visit the URL and I got a 500. So I went to the Apache2 logs to check if something was wrong and I saw the same RuntimeException
again.
EDIT
So I've also followed the instructions of this link but unfortunately, same results. I also checked if I've got everything installed correctly such as ACL and I did.
I also did an getfacl /my/path/var/cache
and it showed the correct information based on this link.
EDIT #2
I've also already run php bin/symfony_requirements
and it showed me that 'My system is ready to run Symfony Projects', even after php bin/console cache:clear --env=prod --no-debug