Where to put custom settings in Zend Framework 2?

前端 未结 4 1616
有刺的猬
有刺的猬 2021-02-04 10:47

I have some custom application specific settings, I want to put in a configuration file. Where would I put these? I considered /config/autoload/global.php and/or local.php. But

4条回答
  •  醉酒成梦
    2021-02-04 11:07

    You use your module.config.php

    return array(
        'foo' => array(
            'bar' => 'baz'
        )
    
      //all default ZF Stuff
    );
    

    Inside your *Controller.php you'd call your settings via

    $config = $this->getServiceLocator()->get('config');
    $config['foo'];
    

    It's as simple as that :)

提交回复
热议问题