View Source

<ac:macro ac:name="info"><ac:parameter ac:name="title">Zend_Config_Json</ac:parameter></ac:macro>
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}


[Sudheer Satyanarayana|]


1.0 - 22 November 2009: Initial Draft.

Zend_Config_Json reads a text configuration file whose contents are in JSON format.

* [Wikipedia page |]
* [|]

* This component *will* read a configuration file whose contents are in JSON format
* The component *will* support configuration sections
* This component *will* will not save information to the storage media. Zend_Config_Writer_Json will be proposed once we freeze the specification of this component.

* Zend_Config
* Zend_Json

This component works much like Zend_Config_Ini and Zend_Config_Xml offering another data format support - JSON.

* Milestone 1: Complete writing this proposal
* Milestone 2: Working prototype checked into the incubator
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.

* Zend_Config_Json
* Zend_Config_Writer_Json


production: {
webhost: ""
database: {
adapter: "pdo_mysql"
params: {
host: ""
username: "dbuser"
password: "secret"
dbname: "mydatabase"
staging: {
configOptions: {
extends: "production"
webhost: ""

The wiki doesn't seem to allow me to print curly braces. For now, please assume the contents of the file are enclosed within curly braces.

I have attached the sample JSON configuration file to this proposal.

In a PHP script
$config = new Zend_Config_Json('application/configs/database.json', 'staging');
echo $config->database->params->webhost; // prints ""
echo $config->database->params->dbname; // prints "mydatabase"


class Zend_Config_Json extends Zend_Config {}
class Zend_Config_Writer_Json extends Zend_Config_Writer {}