Zend framework *.ini配置中的应用程序路径,它是如何工作的?

Zend framework *.ini配置中的应用程序路径,它是如何工作的?,zend-framework,Zend Framework,*.ini文件有一个常量:应用程序路径 应用程序路径是何时设置的,它是如何工作的 例如,请参见下面的代码 您应该在public\u html/index.php中找到它的定义。应用程序路径是ZendFramework用于确定项目部署/安装位置的php常量。它通常在newproject/public/index.php中定义,即 // Define path to application directory defined('APPLICATION_PATH') || define('AP

*.ini
文件有一个常量:
应用程序路径

应用程序路径是何时设置的,它是如何工作的

例如,请参见下面的代码
您应该在
public\u html/index.php

中找到它的定义。应用程序路径是ZendFramework用于确定项目部署/安装位置的php常量。它通常在newproject/public/index.php中定义,即

// 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不是php类/文件,它是一个配置文件,这意味着它遵循不同的语法

要将字符串和常量连接在一起,只需将它们相邻放置,不使用点(.)运算符。需要注意的一点是,必须使用双引号(“),否则将不会计算该常量

有关更多信息,您可以查看parse_ini()函数的文档,ZendFramework使用该函数解析配置文件

参考资料: http://php.net/manual/en/function.constant.php

Zend框架使用两个重要的动态常量(应用程序路径、应用程序环境)来确保整个框架在其托管的任何位置都能正常工作


它必须在使用之前进行初始化。因此在index.php中进行了初始化,因为每个请求都将通过zend framework中的index.php进行处理。

它是如何工作的?因为我认为在配置中:
includePaths.library=APPLICATION\u PATH。“/../library”
,这里需要有。(点运算符)。(cc:@Basmayor)@vietean我在我的回答中添加了更多细节,以便它也反映了对您评论的回答
// 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();