I'm currently setting up an Webserver on a RaspberryPi with Raspbian 9 and want to deploy a productive Symfony4 Webpage on it.
For that case I created a vHost File in Apache2 with the needed Environment-Variables in it. But as I'm executing "composer install --no-dev" (because I don't want to use dotenv) I'm getting the error "PHP Fatal error: Uncaught RuntimeException: APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file."
When creating a test.php file in Symfonys Public Folder and querying "echo $_SERVER['APP_ENV']" I'm getting correctly the setted "prod" Variable.
Thanks for your help!
Attached the anonymized vHost File:
<VirtualHost *:80>
ServerName gate.keeper
ServerAlias www.gate.keeper
DocumentRoot /var/www/gk3/public
<Directory /var/www/gk3/public>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/gk3>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/gk3/public/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/gk3_error.log
CustomLog /var/log/apache2/gk3_access.log combined
# optionally set the value of the environment variables used in the application
SetEnv APP_ENV "prod"
SetEnv APP_SECRET "secret"
SetEnv DATABASE_URL "mysql://user:password@localhost:3306/db_name"
</VirtualHost>