Reputation: 377
This must be a simple thing but I still couldn't read resourse values from application.ini in Zend framework 2 after going through several threads. I have a module and inside the module I have a controller.I want to get the values in resourse file in this controller.
namespace myModule\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
class myController extends AbstractActionController
{
public function handlerAction() {
// I want to read application.ini values here
}
}
application.ini
is as below:
[lables]
dom.title = Lable 01
I tried to get this values with,
$config = $this->getApplication()->getOption('dom');
But still no luck. Help me to figure this out.
Thankx
Upvotes: 0
Views: 258
Reputation: 4315
Use php native function parse_ini_file()
. Because you have sections (I suppose it is labels
instead of lables
), use it this way:
$iniArray = parse_ini_file($pathToFile . DIRECTORY_SEPARATOR . 'application.ini', true);
$domTitle = $iniArray['labels']['dom.title'] ;
Upvotes: 1