2011-05-11 24 views
4

一直試圖覆蓋我的應用程序/ modules/module5/config/module.ini中的phpSettings.display_errorszend模塊特定的ini與phpSettings.display_errors

我的單詞數/ bootstrap.php中有

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

因此該文件被正確解析,但同時那些在給定module.ini中越來越忽視了在給定的application.ini的phpSettings越來越加載。

雖然在我的應用程序/引導程序,我可以得到$ this-> getAPplication()正確。 PHP設置生效。而在應用程序/模塊/ module5/Bootstrap.php Im我鬆散的應用程序對象,getApplication()返回Bootstrap而什麼也不做,PHP設置不會被激活。

回答

2

看着filesystem,你的module.ini文件不應該在你的模塊的配置文件夾中,而應該改爲application.ini嗎?

0

呃,我對應用程序瞭解不多,但在我看來,它並不是一個Bootstrap對象。看着我的轉儲,似乎Zend_Application實際上與它相關聯。它似乎也有您正在尋找的細節:

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] 

其實我不知道爲什麼你有問題,你將不得不給我們一些轉儲。

它工作時,我嘗試:

<?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')); 
    } 
} 

這是我的佈局:

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

這是我的輸出:

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) 

工作正常,我。

+0

在我的應用程序/引導程序中,我可以正確地獲得$ this-> getAPplication()。 PHP設置生效。而在應用程序/模塊/ module5/Bootstrap.php Im我鬆散的應用程序對象,getApplication()返回Bootstrap而什麼也不做,PHP設置不會被激活。 – thevikas 2011-05-12 02:47:55

0

假設你真正關心的開啓/關閉PHP display_error設置的東西,你可能只是想這樣做:

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

所以,如果這並不爲你工作,刪除所有行APPART從您的display_errors設置中,從該命名的額外ini文件中,在上面提到的代碼之後添加以下行,並在此處發佈結果。

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