You'd generally store your "sensitive" env vars in a .env.*.php file in your root, which are by default ignored by git for safety reasons. I.e. you create them on local machine and are than ignored when you do git push.
I don't have much experience with forge, but you should have a page where you can create your env vars that are than applied to laravel without actually saving them inside the project.
pogachar said:
You'd generally store your "sensitive" env vars in a .env.*.php file in your root, which are by default ignored by git for safety reasons. I.e. you create them on local machine and are than ignored when you do git push.
I don't have much experience with forge, but you should have a page where you can create your env vars that are than applied to laravel without actually saving them inside the project.
That's exactly right, I'm sing the Laravel Forge page which are generating correct .env.*.php files and the getenv are also correct. But the config doesn't seem to read the correct, I've no clue why,
I'm having the exact same problem, and I'm really keen for an answer. php artisan env
returns the correct environment, and my app can use all the env vars fine, but artisan can't seem to read them properly, through commands, or Tinker. Desperately hope there's an answer for this soon, it's beyond frustrating. I reached out to Taylor, and he simply didn't know why. I'm glad someone else is getting this issue, so it might get some more attention.
Try changing to
'host' => $_env['DB_HOST'],
'database' => $_env['DB_NAME'],
'username' => $_env['DB_USERNAME'],
'password' => $_env['DB_PASSWORD'],
Watch the free series Server management with Forge on Laracasts.
syropian said:
I'm having the exact same problem, and I'm really keen for an answer.
php artisan env
returns the correct environment, and my app can use all the env vars fine, but artisan can't seem to read them properly, through commands, or Tinker. Desperately hope there's an answer for this soon, it's beyond frustrating. I reached out to Taylor, and he simply didn't know why. I'm glad someone else is getting this issue, so it might get some more attention.
It's really frustrating indeed,
pogachar said:
Try changing to
'host' => $_env['DB_HOST'], 'database' => $_env['DB_NAME'], 'username' => $_env['DB_USERNAME'], 'password' => $_env['DB_PASSWORD'],
Watch the free series Server management with Forge on Laracasts.
I tried a var_dump of $_ENV. I can only see the DB_NAME with that. So something is completly borken I guess. :) I'll try to research it further and return with an answer I hope.
I've watched that serie on Laracasts and that's the reason why I first got in touch with Homestead and Forge, really good serie, indeed! :)
I found an answer in my post at Stack Overflow. I don't know why there's an error but it seems like If you're writing production in the environment field at Forge it won't work so skip to write anything in that field and It will work.
The solution is quoted as this: Make sure you're env file is called .env.php and not .env.production.php. I made this mistake, and although having .env.production.php will work in app, it won't when using Artisan.
When creating env vars within Forge, if it's for a production environment, be sure to leave the environment field blank, as opposed to explicitly setting it to production.
Oops, forgot to ping you on here when I answered on SO. Glad it's working for you too :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community