SetEnv APPLICATION_ENV development - .htaccess interacting with Zend Framework?

后端 未结 2 1455
傲寒
傲寒 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 15:07

    SetEnv, used in Apache's configuration (be it a .htaccess file, or a VirtualHost), defines an environment variable.

    From PHP, you can read environment variables either :

    • using the getenv() function.
    • Or in the $_SERVER or $_ENV superglobal variables


    Taking a look at the given index.php in Zend Frameworks QuickStart, you'll see it uses that environment variable the define the PHP constant called APPLICATION_ENV :

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

    And that constant is later used to initialize the application :

    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/configs/application.ini'
    );
    

提交回复
热议问题