Reputation: 155
I have a staging server setup something like this: http://staging.mysite.com
the method below works just fine for my development environment.
In the .htaccess file, i included:
SetEnv APPLICATION_ENV "staging"
Yet Zend still thinks the environment is production.
<title>My Site :: <?= APPLICATION_ENV; ?></title>
yields:
My Site :: production
in the title bar of the browser.
I have searched multiple threads and tried using the SetEnvIf directive as well with no luck.
Please help!
Upvotes: 1
Views: 7052
Reputation: 31
Under my local server running php on fcgi, the following .htaccess
directive
SetEnv APPLICATION_ENV development
results in the following $_SERVER
variable
...
[REDIRECT_APPLICATION_ENV] => development
...
Upvotes: 3
Reputation: 13296
Try to remove the double quote:
SetEnv APPLICATION_ENV staging
and check the return of getenv
in PHP:
echo getenv('APPLICATION_ENV');
Upvotes: 2
Reputation: 33148
SetEnv
simply sets the Apache environment variable, you can access this with PHP in $_SERVER
or using PHP's getenv() function as ZiTAL posted above. You probably want something like this somewhere early in your app (e.g. index.php):
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
This populates the constant with the environment variable value unless it is already defined, falling back to the value of 'production' if the env var isn't populated.
Upvotes: 3