kay899's avatar

How does the .env.php has to look?

Hi, it's my first try with forge and I really are in trouble. I didn't get my database running. Always have errors like root@localhost not found...

1) Do I really have to add APP_ENV (=production) as Enviroment Variable?

2) Do I have to add an .env.php file myself? And then upload it via Bitbucket...?

3) How exactly does the .env.php file has to look like?

Thanks Kay

0 likes
4 replies
fraserk's avatar

On Forge, you have to manually add your environment variables. Its located under site detail->environment. You have to set you database info there.

kay899's avatar

I did this for the DB variables.

But what about my questions?

fraserk's avatar

The .env file is only use for locally. its not being commited.

chrisgeary92's avatar
Level 13

I'm assuming you are using L4, as L5 doesn't have a .env.php file..

1) It depends on your environment checking. L4 by default checks your servers host name, not the value of APP_ENV

2) You can add environment variables using forge as @fraserk has mentioned. If you prefer to do it the manual .env.php way then yes you will have to upload this yourself with ssh/sftp etc. The idea is this file doesn't exist in your git repo, because it contains all your api keys, and passwords etc.

3) It's just an array of data that you return, something like this:

<?php

return [
     'DB_PASSWORD' => 'np9c8y2bc9nt2px8d',

     'DB_USER' => 'forge',

     'DB_NAME' => 'mydatabase',

     // And so on...
];

Please or to participate in this conversation.