title: Symfony3 Export To Production
body: <p>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</p>
  <pre><code>sudo composer install --no-dev --optimize-autoloader 
  </code></pre>
  <p>I get the error:</p>
  <blockquote>
  <p>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</p>
  </blockquote>
  <pre><code>[RuntimeException]
  An error occurred when executing the &quot;'cache:clear --no-warmup'&quot; command: PHP Fatal error:  Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle'not found in /my/path/app/AppKernel.php on line 25.
  </code></pre>
  <p>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:</p>
  <pre><code>export SYMFONY_ENV=prod
  </code></pre>
  <p>After that I executed the <code>composer install</code> command again but, same results.</p>
  <p>Some people on Stackoverflow (and other sources) said that I need to clear my cache by executing</p>
  <pre><code>sudo bin/console cache:clear --env=prod
  </code></pre>
  <p>So I did that but same results. Anyone any idea?</p>
  <p>Other solutions tried:
  Actually it works great whenever I execute the command this way:</p>
  <pre><code>sudo SYMFONY_ENV=prod composer install --no-dev --optimize-autoloader 
  </code></pre>
  <p>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 <code>RuntimeException</code> again.</p>
  <p><strong>EDIT</strong></p>
  <p>So I've also followed the instructions of this <a href="http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup" rel="nofollow noreferrer">link</a> but unfortunately, same results. I also checked if I've got everything installed correctly such as ACL and I did.</p>
  <p>I also did an <code>getfacl /my/path/var/cache</code> and it showed the correct information based on this <a href="https://www.digitalocean.com/community/tutorials/how-to-deploy-a-symfony-application-to-production-on-ubuntu-14-04" rel="nofollow noreferrer">link</a>.</p>
  <p><strong>EDIT #2</strong></p>
  <p>I've also already run <code>php bin/symfony_requirements</code> and it showed me that 'My system is ready to run Symfony Projects', even after <code>php bin/console cache:clear --env=prod --no-debug</code></p>