使用できるコンテナ --
サポートされるフォーマット
使用できるコンテナ
- Apache
Apache 設定ファイルをパースし、保存します。
このコンテナではオプションは提供されていません。
- GenericConf
汎用の設定ファイルです。等号、コメントの開始文字、
改行文字などを独自に設定し、
お好みの設定フォーマットにマッチさせることができます。
表 37-1使用できるオプション
| オプション | データ型 | デフォルト値 | 説明 |
|---|
|
"comment"
|
string
|
"#"
|
コメントの開始を意味する文字。
|
|
"equals"
|
string
|
":"
|
キーと値を区切る文字。
|
|
"newline"
|
string
|
"\"
|
値が複数行にまたがることを意味する文字。
|
- IniCommented
標準 INI ファイルをパースし、ファイル内のコメントも維持します。
このコンテナではオプションは提供されていません。
- IniFile
標準 INI ファイルを、PHP 組み込み関数の
parse_ini_file() を使用してパースします。
コメントは読み込みません。
このコンテナではオプションは提供されていません。
- PHPArray
PHP の配列をパースします。PHP のソースファイル、
あるいはメモリ上の配列から読み込めます。
技術的な制限により、このコンテナは、
設定ファイルから読み込む際に空行やコメントをパースできません。
そのため、PHP コメント内の情報は失われます。
表 37-2使用できるオプション
| オプション | データ型 | デフォルト値 | 説明 |
|---|
|
"name"
|
string
|
"conf"
|
ルート設定値として使用する名前。
PHP ソースファイルのパースおよび書き込みの両方に使用します。
|
|
"useAttr"
|
boolean
|
TRUE
|
属性をパースして保存するかどうか。
|
| 警告 |
PHP の配列を含む設定ファイルを読み込む際には標準的な PHP
のメソッドを使用するので、保存する際にはコードのコメントや構造は失われます。
|
- PHPConstants
PHP のソースファイルから、PHP の define()
をパースします。このコンテナではコメントは保持されますが、
空行は失われます。
このコンテナではオプションは提供されていません。
- XML
XML_Parser.
を使用して XML ファイルをパースします。
表 37-3使用できるオプション
| オプション | データ型 | デフォルト値 | 説明 |
|---|
|
"version"
|
string
|
"1.0"
|
使用する XML バージョン。
|
|
"encoding"
|
string
|
"ISO-8859-1"
|
データをパースしたり保存したりする際に使用するエンコーディング。
|
|
"name"
|
string
|
"conf"
|
PHPArray と同様、設定全体のルートの名前を定義します。
|
|
"indent"
|
string
|
" "
|
XML ドキュメントを書き出す際の字下げに使用する文字。
デフォルトでは空白二文字を使用します。
|
|
"linebreak"
|
string
|
"\n"
|
XML ドキュメントを書き出す際の改行に使用する文字。
|
|
"addDecl"
|
boolean
|
TRUE
|
XML 宣言を XML ドキュメントの先頭に追加するかどうか。
|
|
"useAttr"
|
boolean
|
TRUE
|
属性をパースして保存するかどうか。
|
|
"isFile"
|
boolean
|
TRUE
|
TRUE の場合、parseConfig() の最初の引数は
XML ファイルのファイル名として扱います。
FALSE の場合は、引数は XML データ自体として扱われ、パースされます。
|
|
"useCData"
|
boolean
|
FALSE
|
データを CDATA ブロックで囲むかどうか。
|
|
設定の編集 (Previous)
|
(Next) Config::Config
|
|
|
Download Documentation
|
Last updated: Sun, 31 Aug 2008 |
|
Do you think that something on this page is wrong? Please file a bug report or add a note.
|
| User Notes: |
Note by: awgrover@msen.com
Here's some example config-file formats for PHP 5.1.2, Pear 1.6.2 Config 1.10.11.
Using the example code from this package's Introduction (../package.configuration.config.intro.php),
adding a blank-line and comment, and using defaults.
Apache
Described in http://httpd.apache.org/docs/2.0/configuring.html
<conf>
<DB>
type mysql
host localhost
user root
# this is a comment (after a blank line)
pass root
</DB>
</conf>
GenericConf
No sections. Apparently simple "key:value" lines.
type:mysql
host:localhost
user:root
#this is a comment (after a blank line)
pass:root
IniCommented
Apparently the Windows ini format
Useful reference: http://search.cpan.org/~wadg/Config-IniFiles-2.38/IniFiles.pm#FILE_FORMAT
[conf]
[DB]
type = mysql
host = localhost
user = root
;this is a comment (after a blank line)
pass = root
PHPArray
A bunch of array assignments. PHP code. Presumably does "include" or "eval". Arbitrary code probably possible.
<?php
$conf['conf']['DB']['type'] = 'mysql';
$conf['conf']['DB']['host'] = 'localhost';
$conf['conf']['DB']['user'] = 'root';
// this is a comment (after a blank line)
$conf['conf']['DB']['pass'] = 'root';
?>
PHPConstants
A bunch of "define()". Does not recognize/use sections. PHP code. Presumably does "include" or "eval". Arbitrary code probably possible.
<?php
/**
*
* AUTOMATICALLY GENERATED CODE -
DO NOT EDIT BY HAND
*
**/
//
// conf
//
//
// DB
//
define('type', 'mysql');
define('host', 'localhost');
define('user', 'root');
// this is a comment (after a blank line)
define('pass', 'root');
?>
XML
Straight-forward nested xml. Does not respect blank-lines.
<?xml version="1.0" encoding="ISO-8859-1"
|
|