SetEnv APPLICATION_ENV development - .htaccess interacting with Zend Framework?

后端 未结 2 1431
傲寒
傲寒 2021-01-30 14:05

I have the following on my htaccess.

SetEnv APPLICATION_ENV development

When I pass this file to prodution, I will change it to:



        
2条回答
  •  无人及你
    2021-01-30 14:56

    The flow of communication, as you call it, is the followoing:

    If you use

    SetEnv APPLICATION_ENV production

    in your .htaccess, the environment you set there, will be used. Why?

    The following piece of code from your index.php doesn't define the constant, if it has been defined already, which is the case, if you use SetEnv in your .htaccess.

    // Define application environment
    defined('APPLICATION_ENV')
        || define('APPLICATION_ENV',
                  (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
                                             : 'production'));
    

    If your .htaccess doesn't define the constant, the value provided in the index.php will be used. If I were you, I would still keep it in sync. Because you may make mistakes like forgetting to set AllowOverride for your vhost which would result in a situation where the environment is set by the index.php even though the .htaccess is present.

提交回复
热议问题