开发者

APPLICATION_PATH in *.ini configuration, how does it work?

开发者 https://www.devze.com 2023-04-12 01:27 出处:网络
An *.ini file has a constant: APPLICATION_PATH When is APPLICATION_PATH set and how does it work? See the below code for instance

An *.ini file has a constant: APPLICATION_PATH

When is APPLICATION_PATH set and how does it work?

See the below code for instance

; application/configs/application.ini
 
[production]
; PHP settings we want to initialize
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers&quo开发者_如何学JAVAt;
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"


APPLICATION_PATH is a PHP constant used by ZendFramework to determine where you deployed/installed your project. It's usually defined in newproject/public/index.php i.e.

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH',
              realpath(dirname(__FILE__) . '/../application'));

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

/** Zend_Application */
require_once 'Zend/Application.php';

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

Application.ini is not a php class / file, it is a configuration file which means it follows a different syntax.

To concatenate strings and constants together, you simple put them next to each other, you don't use the dot (.) operator. One thing to watch out for is that you have to use double quotes ("), otherwise the constant will not be evaluated.

For more information, you can look into the documentation of the parse_ini() function, which is the function that's used by ZendFramework to parse configuration files.

References: http://php.net/manual/en/function.parse-ini-file.php http://php.net/manual/en/function.constant.php http://framework.zend.com/manual/en/zend.application.quick-start.html


You should find its definition in public_html/index.php


Zend Frameworks uses two important dynamic constants(APPLICATION_PATH, APPLICATION_ENV) for entire framework to work correctly in what ever location it is hosted.

it has to be initialised before there are used. so there are initialised in the index.php as every request will go through the index.php in zend framework.

0

精彩评论

暂无评论...
验证码 换一张
取 消