PHP Zend Framework - Zend_Config and Global State

I am exploring the benefits of Zend_Config_Ini compared to using a simple constant file.

eg. -

define('DB_HOST',localhost);

//versus

$config = new Zend_Config_Ini('/path/to/config.ini', 'staging');
echo $config->database->params->host;   // prints "dev.example.com"

The only thing is that $ config is not globally accessible. So, you need to use Zend_Registry to store applications, without having to run it every time.

This seems to add more complexity than necessary .... Am I missing something or is Zend_Config + Zend_Registry a method that is better in the long run as the application grows?

+3
source share
3 answers

- . , lib , lib DB_HOST. .

, Zend Framework . Zend_Db - . $this->database, , , .

, . . Fowler.

+4

Zend_Config , " PHP"; .ini - .ini PHP-.

.ini/XML - /!

.ini Zend_Config , ; , (.. "" "" "", )


, Zend_Config, : Zend Framework Zend_Application , ; ? ?

Framework, Zend_Config; , : -)


PHP .ini, , , , , .ini (And Zend_Config + Zend_Registry ).

+1

, , Zend , . , , -

- , , , . , DB_HOST? , , , ?

, . ? (, ..) , , , , , ? , ?

Zend_Config "" . , , .

+1

Source: https://habr.com/ru/post/1724045/


All Articles