avatarphp  

php Zend Config Json

Meinerseits ist ja ein JSON-Fantiker und ein großer Freund vom Zend Framework.
Leider Gottes gab es nie eine Schnittstelle um mit Zend_Config auch JSON Files
zu öffen und ein zulesen, das hat sich jetzt geändert, ich präsentiere:

Fate_Config_Json (github)

// our config file
$file = dirname(__FILE__) . '/data/config.json';

// create a new config object and and parse the file
// but only loads the section 'development' which
// inherits from the section 'production'
$config = new Fate_Config_Json($file, 'development');

//the result converted to an array
print_p($config->toArray());


Ich setze die Klasse schon effektiv in Projekten ein und
man kann dann eine, nach meiner Meingung nach bessere
Strukturierung von Daten erhalten als in XML oder Ini-Files:

{
"production": {
"phpSettings": {
"display_startup_error": false,
"display_errors": false
},

"includePaths": {
"library": "$APPLICATION_PATH/library"
},

"bootstrap": {
"path": "$APPLICATION_PATH/usr/Bootstrap.php",
"class": "Bootstrap"
},

"doctrine": {
"connections": {
"blog": "sqlite:///$APPLICATION_PATH/opt/doctrine/data/sql/blog.sql"
},
"options": {
"data_fixtures_path": "$APPLICATION_PATH/opt/doctrine/data/fixtures",
"models_path": "$APPLICATION_PATH/opt/models",
"migrations_path": "$APPLICATION_PATH/opt/doctrine/migrations",
"sql_path": "$APPLICATION_PATH/opt/doctrine/data/sql",
"yaml_schema_path": "$APPLICATION_PATH/opt/doctrine/schema"
}
},

"resources": {
"frontcontroller": {
"moduledirectory": "$APPLICATION_PATH/usr",
"defaultmodule": "sites",
"throwerrors": true,
"params": {
"prefixDefaultModule": true
},

"plugins": [
"Fate_Controller_Plugin_ModuleConfig",
"Fate_Controller_Plugin_Doctrine"
],

"loader": {
"registerNamespace": [
"Hermes_",
"Fate_",
"Doctrine_"
]
}
},

"view": [],

"modules": "",

"layout": {
"default": "default",
"blog-admin": "admin"
},

"router": {
"routes": {

"index": {
"route": "",
"defaults": {
"controller": "index",
"action": "index",
"module": "sites"
}
},

"blog": {
"route": "blog",
"defaults": {
"controller": "index",
"action": "index",
"module": "blog"
}
},

"blog-admin": {
"route": "blog/admin",
"defaults": {
"controller": "admin",
"action": "index",
"module": "blog"
}
},

"blog-admin-articles": {
"route": "blog/admin/articles",
"defaults": {
"controller": "admin",
"action": "index-article",
"module": "blog"
}
},

"blog-admin-articles-new": {
"route": "blog/admin/articles/new",
"defaults": {
"controller": "admin",
"action": "new-article",
"module": "blog"
}
},

"blog-admin-articles-edit": {
"route": "blog/admin/articles/edit/:id",
"defaults": {
"controller": "admin",
"action": "edit-article",
"module": "blog"
}
}
}
}
}
},


"development:production": {
"phpSettings": {
"display_startup_error": true,
"display_errors": true
}
}
}

Kommentare (3)

  
+
+1
Ich setze die Klasse schon effektiv in Projekten ein und
man kann dann eine, nach meiner Meingung nach bessere
Strukturierung von Daten erhalten als in XML oder Json


Hast du dich da vertan? ;)
avatar

unset

  • vor ungefähr 8 Monaten
+
+1
Japp. sollte ini heißen :D Thx
avatar

unsicherheitsagent

  • vor ungefähr 8 Monaten
+
0
Json ist mir auch lieber, als XML. Schlanker, einfacher auszulesen…
avatar

BuzzEins

  • vor ungefähr 8 Monaten

 



Ihre Email bleibt unsichtbar


jeder zweite dofollow :)