I use Github to deploy my sites on my production server. Because of this, I do not want to store .env files. *. Php so they are in my .gitignore.
Inside each environment directory, I set up the database configuration to use getenv() , for example:
<?php 'connections' => array( 'mysql' => array( 'driver' => 'mysql', 'host' => getenv('DB_HOST'), 'database' => getenv('DB_NAME'), 'username' => getenv('DB_USERNAME'), 'password' => getenv('DB_PASSWORD'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), ), );
Then I went into the apache conf file for my virtual hosts and set the environment variables, for example:
SetEnv DB_HOST ***.***.***.*** SetEnv DB_NAME database SetEnv DB_USERNAME databaseuser SetEnv DB_PASSWORD databasepass
All this works fine on a production server.
However, I only manually imported the database at the moment, and not using php artisan migrate , because it does not work.
I know that this does not work because it does not hit the Apache, so the variables are not set, but I tried many ways to try to work around this problem, but I have not been lucky yet.
I tried to make the environment see if it can get variables using php artisan --env=production migrate
I also tried to verify that it was using the correct environment by running php artisan env and using the correct production environment.
My next idea was to create the .env.production.php file manually on a production server. I created one and used getenv () just in case it worked like that, but the same error occurred, so I tried to set the variables manually without using getenv (), and I still had no luck.
We will be very grateful for any ideas.