开发者

zend module specific ini with phpSettings.display_errors

Been trying to override the phpSettings.display_errors from my application/modules/module5/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());
}

so the file is parsing properly but the the phpSettings given in application.ini are getting loaded while those given in module.ini are getting ignored.

While on my application/Bootstrap I can get $this->getAPplication() properly. php settings take effect. while Im on application/modules/module5/Bootstrap.php I loose the application object, getApplication() returns Bootstr开发者_开发技巧ap while does nothing, php settings don't get activated.


Looking at the filesystem, shouldn't your module.ini file be in a config folder in your module and be called application.ini instead?


Meh, I don't know much about application, but there's nothing wrong with it being a Bootstrap object in my opinion. Looking at my dump it seems the Zend_Application is actually associated with it. It also seem to have the details 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]

I actually don't get why you have a problem, you are going to have to give us some dumps.

It works when I try it:

<?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 output:

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 fine for me.


Assuming the thing you really care for is switching on/off the php display_error setting, you might just want to 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 doesn't work for you, delete all lines appart from your display_errors setting from that named, extra ini file and add the following lines after the code mentioned above and post the result here.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜