Reputation: 225
I was trying to run my project for the first time in a production environment I did not go how I expected.
After following the instructions from here
https://symfony.com/doc/current/deployment.html I got an error in my localhost/Symfony/web/app_dev.php
page :
ClassNotFoundException: Attempted to load class "SensioGeneratorBundle" from namespace "Sensio\Bundle\GeneratorBundle" in D:\logiciel\wamp\www\Symfony\app\AppKernel.php line 28. Do you need to "use" it from another namespace?
Is it possible that composer made a mistake or something? I really don't know how to solve this
Upvotes: 12
Views: 5660
Reputation: 6940
It may be a bit out of scope, but I would like to add to Pogus's answer that if you are using Ansible for running composer, you have to provide this env variable like this:
- name: "Install your app dependencies"
composer:
command: install
no_dev: yes
optimize_autoloader: yes
working_dir: "/your/app/dir"
environment: # <---- here
SYMFONY_ENV: prod # <---/
...or in a similar way, read the Ansible environment variables docs for details.
Setting it places like /etc/profile.d/set-symfony-env-to-prod.sh
scripts will be used by programs running on your server, but NOT by Ansible.
Upvotes: 0
Reputation: 451
I had the same problem and solved it by doing:
export SYMFONY_ENV=prod
Upvotes: 34