(Zend Framework> Zend_Config) How to avoid using .ini or .xml config?

I don’t think that using .ini or .xml files is a good idea for high traffic projects, because each page load causes the config.ini or .xml file to be parsed.

Is there a way to replace using.ini / .xml with a regular php array as config? Now php ini looks like this ...

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "Europe/London"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = rob
resources.db.params.password = 123456
resources.db.params.dbname = zf-tutorial
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view.doctype = "XHTML1_STRICT"

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

I want something like this ...

<?php

$config = array(
    'production' => array(
        ['phpSettings.display_startup_errors'] => 0,
        ['phpSettings.display_errors'] => 0,
    ),
);

Is it possible? What should I do and how can I tell the application to use my own Config.php?

Thanks and sorry for my english.

UPD : I think passing an array to the Zend_Application constructor is the right way?

+5
source share
3 answers

, Zend_Config; Zend Framework (, arround # 1):

, Zend_Config_Ini Zend_Config_Xml, PHP, Zend_Config , -


# 2 ( , arround it):

PHP . ,

, PHP, :

// config.php
return array(
  ...
  ...
);

:

$config = new Zend_Config(require 'config.php');


, , .ini, , , ( ) .

, , Zend_Config:

  • .ini
  • mecanism
  • .ini.
+8

php.ini. , - .

+1

, , APC . .ini Zend_Config CPU, toArray().

+1
source

All Articles