I have 2 sites on my digitalocean droplet using forge.
The production and the test site. I've created several ENV variables (including the variable ENVIRONMENT = production) on my production site which work fine.
However, nothing works on my test site. Any environment variable I create simply is not available in $_ENV...
currently I have these 3 files:
.env.php
.env.staging.php
.env.test.php (somehow magically created)
I think the problem here is that your staging server doesn't "know" its staging yet, since you declare its environment in an environment variable that is loaded depending on environment variables to be loaded.
What I do is to set the ENVIRONMENT environment variable (testing, staging, production) in the Forge configuration, then load any other environment variables using the .env.php files. See if that does it for you.
It's not a separate server just to be clear :) It's 1 server with 2 sites. The test/staging (they are the same site, bad naming i know) and the production.
I did set the ENVIRONMENT variable in every possible way on the staging site but it just won't load anything. It's in the nginx config file as well.
Just to be clear: have you gone in Forge Site>Site Details>Environment and set the following:
If you did that and it still doesn't work, have you verified your environment detection is set up correctly (in /bootstrap/start.php for Laravel 4.2). If so, I'm at a loss as well.
Are you using Laravel 5? If so, it may be a bug, since things are in constant flux in preparation for release.
I got it to work by removing all the env stuff and starting from scratch. However, I realized that it simply did not work in artisan. Which is a bummer because I was spending so much time testing it in there :')
That will detect correctly in homestead, as it uses the machine name for detection, and not a domain name. To get it to work with both, you need to use a combination tactic. :)