Monday, December 9, 2013

ZF2 : Custom config file inside module(s)

Hi,

ZF2 has the feature to create custom config file inside module(s).

Its provide help to declared variable those will used inside the particular module.

It is independent of main ZF2 config file.

Below are step to create/Use the custom config file inside the module:

Step 1: Create Module as Report

Step 2: Create custom config file in module's config directory i.e. module.customconfig.php, 

Step 3: Sample content inside module.customconfig.php

return array(
         'report' => array(
              'header' => array(
                    'name' => 'Name'
               )
         ),
);


Step 4: In controller of Report Module, Ex: ReportController.php

In Action: 

$config = $this->getServiceLocator ()->get ( 'config' );
//Take custom-config data from config file
$data = $config['report'];
print_r($data);




No comments :