diff --git a/en/reference/config.rst b/en/reference/config.rst index b6cb1e8de73e..70d0fe3ba1dc 100755 --- a/en/reference/config.rst +++ b/en/reference/config.rst @@ -149,3 +149,38 @@ The above code produces the following: ) There are more adapters available for this components in the `Phalcon Incubator `_ + +Injecting Configuration Dependency +---------------------------------- +You can inject configuration dependency to controller allowing us to use :doc:`Phalcon\\Config <../api/Phalcon_Config>` inside :doc:`Phalcon\\Controller <../api/Phalcon_Controller>`. To be able to do that, add following code inside your dependency injector script. + +.. code-block:: php + + set('config', function () { + $configData = require 'config/config.php'; + return new Config($configData); + }); + +Now in your controller you can access your configuration by using dependency injection feature using name `config` like following code: + +.. code-block:: php + + config->database->dbname; + } + }