Zend Framework 1.8+: how to automatically install the application environment?

I am developing the application locally with setting up the application development environment. I think this is being installed in a file .htaccess.

Then I deployed the new versions to the production server.

I do not want to manually change the application environment manually each time a new version is deployed.

How can I do this, so I can automatically set the application environment variable (perhaps based on the location that it is located? Ie myapp.comvs. myapp.local)?

+3
source share
3 answers

You can do this in the server, virtual host, directory or .htaccess configuration via

 SetEnv SPECIAL_PATH /foo/bin

Ref.

<VirtualHost host1>
SetEnv FOO bar1
...
</VirtualHost>
<VirtualHost host2>
SetEnv FOO bar2
...
</VirtualHost>

For more details

http://httpd.apache.org/docs/1.3/mod/mod_env.html#setenv

http://docstore.mik.ua/orelly/linux/apache/ch04_06.htm

+4
    if (false !== stripos($_SERVER['HTTP_HOST'], 'yourdomain.tld')) {
        $_ENV['APPLICATION_ENV'] = $_SERVER['APPLICATION_ENV'] = 'production';
    }

index.php

+3

- SM, :

$env = 'development';

if ('www.my-host-name.com' == $_SERVER['HTTP_HOST'] || 'my-server-name' == exec('hostname')) {
    $env = 'production';
}

defined('APPLICATION_ENVIRONMENT') or define('APPLICATION_ENVIRONMENT', $env);
unset($env);

I use my server name to determine the environment. I also use my server name because some scripts are run from a cron job and I need this to run tests.

0
source

Source: https://habr.com/ru/post/1725814/


All Articles