首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Yaf_Application::__construct

(Yaf >=1.0.0)

Yaf_Application::__construct - Yaf_Application构造函数

描述

代码语言:javascript
复制
public Yaf_Application::__construct ( mixed $config [, string $envrion ] )

一个Yaf_Application实例。

参数

config

ini配置文件路径或配置数组

如果是ini配置文件,则应该有一个名为yaf.environ定义的部分,默认为“product”。

注意:如果您使用ini配置文件作为应用程序的配置容器。您将打开yaf.cache_config以提高性能。

和配置条目(和默认值)列表吹:

Example#1一个ini配置文件的例子

代码语言:javascript
复制
[product]
;this one should alway be defined, and have no default value
application.directory=APPLICATION_PATH

;following configs have default value, you may no need to define them
application.library = APPLICATION_PATH . "/library"
application.dispatcher.throwException=1
application.dispatcher.catchException=1

application.baseUri=""

;the php script ext name
ap.ext=php

;the view template ext name
ap.view.ext=phtml

ap.dispatcher.defaultModuel=Index
ap.dispatcher.defaultController=Index
ap.dispatcher.defaultAction=index

;defined modules
ap.modules=Index

envrion

哪一部分将作为最终配置加载

返回值

示例

示例#2 Yaf_Application::__ construct()示例

代码语言:javascript
复制
<?php
defined('APPLICATION_PATH')                  // APPLICATION_PATH will be used in the ini config file
    || define('APPLICATION_PATH', __DIR__)); //__DIR__ was introduced after PHP 5.3

$application = new Yaf_Application(APPLICATION_PATH.'/conf/application.ini');
$application->bootstrap()->run();
?>

上面的例子会输出类似于:

示例#3 Yaf_Application::__ construct()示例

代码语言:javascript
复制
<?php
$config = array(
    "application" => array(
        "directory" => realpath(dirname(__FILE__)) . "/application",
    ),
);

/** Yaf_Application */
$application = new Yaf_Application($config);
$application->bootstrap()->run();
?>

上面的例子会输出类似于:

另请参阅

  • Yaf_Config_Ini

← Yaf_Application::__clone

Yaf_Application::__destruct →

扫码关注腾讯云开发者

领取腾讯云代金券