PHP 8.3.4 Released!

Yaf_Application::__construct

(Yaf >=1.0.0)

Yaf_Application::__constructYaf_Application のコンストラクタ

説明

public Yaf_Application::__construct(mixed $config, string $envrion = ?)

Yaf_Application のインスタンスを作成します。

パラメータ

config

ini ファイルへのパス、あるいは設定の配列。

ini ファイルを指定する場合は、 yaf.environ で定義した名前のセクションが必要です。 デフォルトは "product" です。

注意:

ini ファイルをアプリケーションの設定コンテナとして使うのなら、 yaf.cache_config でパフォーマンスを改善できます。 performance.

設定項目とそのデフォルト値の一覧を示します。

例1 ini ファイルの例

[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.defaultModule=Index
ap.dispatcher.defaultController=Index
ap.dispatcher.defaultAction=index

;defined modules
ap.modules=Index

envrion

最終的な設定として、どのセクションを読み込むか。

戻り値

例2 Yaf_Application::__construct() の例

<?php
defined
('APPLICATION_PATH') // APPLICATION_PATH が ini ファイルで設定されていれば使います
|| define('APPLICATION_PATH', __DIR__));

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

上の例の出力は、 たとえば以下のようになります。


例3 Yaf_Application::__construct() の例

<?php
$config
= array(
"application" => array(
"directory" => realpath(dirname(__FILE__)) . "/application",
),
);

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

上の例の出力は、 たとえば以下のようになります。


add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top