Special zend module with phpSettings.display_errors

There was an attempt to override phpSettings.display_errors from my application / modules / module 5 / config / module.ini.

My module5 / Bootstrap.php has

  protected function _initModuleConfig ()
 {
     $ iniOptions = new Zend_Config_Ini (dirname (__ FILE__). '/configs/module.ini');
     $ this-> getApplication () -> setOptions ($ iniOptions-> toArray ());
 }

therefore, the file is parsed correctly, but the phpSettings parameters specified in application.ini are loaded, and those specified in the .ini module are ignored.

In my / Bootstrap application, I can get $ this-> getAPplication () correctly. Php settings take effect. while Im on application / modules / module5 / Bootstrap.php I lose the application object, getApplication () returns Bootstrap and does nothing, php settings are not activated.

+4
source share
3 answers

Looking at filesystem , your module.ini file module.ini not be in the configuration folder of your module and called application.ini instead?

+2
source

Fur, I know little about the application, but there is nothing wrong with being a Bootstrap object, in my opinion. Looking at my dump, it seems that Zend_Application is actually related to it. It also seems to contain the information you are looking for:

 object(Bootstrap)[3] protected '_appNamespace' => string '' (length=0) protected '_resourceLoader' => object(Zend_Application_Module_Autoloader)[7] protected '_application' => object(Zend_Application)[1] protected '_classResources' => protected '_container' => object(Zend_Registry)[15] protected '_environment' => null protected '_optionKeys' => array protected '_options' => array 'phpSettings' => array 'display_startup_errors' => string '1' (length=1) 'display_errors' => string '1' (length=1) 'date' => array ... 'bootstrap' => array 'path' => string 'C:\sites\mysite\application/Bootstrap.php' (length=39) 'class' => string 'Bootstrap' (length=9) 'resources' => array 'frontController' => array ... 'modules' => array ... 'layout' => array ... 'view' => array ... 'session' => array ... 'log' => array ... 'doctrine' => array ... 'appnamespace' => string '' (length=0) 'autoloadernamespaces' => protected '_pluginLoader' => object(Zend_Loader_PluginLoader)[35] 

Actually, I don’t understand why you have a problem, you have to give us some dumps.

It works when I try:

 <?php class Admin_Bootstrap extends Zend_Application_Module_Bootstrap { protected function _initApp() { $app = $this->getApplication(); echo '1:'; // die(var_dump($app->getOptions())); var_dump($app->getOption('phpSettings')); $app->setOptions(array('phpSettings'=>array('date'=>array('timezone'=>'America/New York')))); echo '2:'; var_dump($app->getOption('phpSettings')); } } 

This is in my layout:

 <?php echo 'in layout'; $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'); var_dump($bootstrap->getOptions()); ?> 

This is my conclusion:

 1: array 'display_startup_errors' => string '1' (length=1) 'display_errors' => string '1' (length=1) 'date' => array 'timezone' => string 'Africa/Johannesburg' (length=19) 2: array 'display_startup_errors' => string '1' (length=1) 'display_errors' => string '1' (length=1) 'date' => array 'timezone' => string 'America/New York' (length=16) in layout array 'phpSettings' => array 'display_startup_errors' => string '1' (length=1) 'display_errors' => string '1' (length=1) 'date' => array 'timezone' => string 'America/New York' (length=16) 

Works great for me.

0
source

Assuming what you really need is to enable / disable the php display_error setting, you can simply do this:

 $iniOptions = new Zend_Config_Ini(dirname(__FILE__) . '/configs/module.ini'); $iniOptions = $iniOptions->toArray(); ini_set ('display_errors',$iniOptions['display_errors'])); 

So, if this does not work for you, remove all the appart lines from the display_errors settings from this named additional ini file and add the following lines after the above code and post the result here.

 var_dump($iniOptions); echo'<hr>'; var_dump(ini_get('display_errors')); die(); 
0
source

All Articles