【问题标题】:Zend autoloading configurations in bootstrap vs application.ini引导程序与 application.ini 中的 Zend 自动加载配置
【发布时间】:2011-08-25 15:33:07
【问题描述】:

给定:

1.
引导:

$autoloader = Zend_Loader_Autoloader::getInstance();// Zend_Loader_Autoloader
$autoloader->registerNamespace('Ntk_');

等于

应用程序.ini:
autoloaderNamespaces[] = "Ntk_"


2.
引导:

$pluginLoader = $this->getPluginLoader();// Zend_Loader_PluginLoader     
$pluginLoader->addPrefixPath('My_Resource', APPLICATION_PATH . "/appResourcePlugins");

等于

应用程序.ini:
pluginPaths.My_Resource = APPLICATION_PATH "/appResourcePlugins"


3.
引导:

$moduleAutoloader = $this>getResourceLoader();//Zend_Application_Module_Autoloader      
$moduleAutoloader->addResourceType('need', 'needs', 'Needs');

等于

应用程序.ini:
???



配置 Zend_Application_Module_Autoloader 的 application.ini 方法是什么?
(...如果存在)
我使用 zend 框架版本 1.11.10

【问题讨论】:

  • resources.modules = "" ?
  • @ArneRie 谢谢,但没有。经过一番挖掘,我的结论是,我想要的默认情况下是不可能的。它必须在引导程序中完成或作为自定义应用程序资源插件实现。

标签: zend-framework autoload zend-application zend-app-bootstrap


【解决方案1】:

也许这个例子会对你有所帮助:

    <?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

protected function _initApplication()
{
$this->bootstrap('frontcontroller');
$front = $this->getResource('frontcontroller');
$front->addModuleDirectory(dirname(__FILE__) . '/modules');
}

protected function _initDoctype()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');
}
}

这里是application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.modules = ""

resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] =

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1 

参考:someone had the same question and got his answer here

【讨论】:

  • 行:resources.modules = "" only unleash Zend_Application_Resource_Modules 是一个应用程序资源插件,它将处理我的其他模块引导过程,我的其他模块可以在resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" 中找到。但是,如果我想添加一个控制器动作助手,例如,我该如何在 application.ini 中做到这一点?知道我可以在引导程序中做到这一点,例如:$loader = $this-&gt;getResourceLoader(); $loader-&gt;addResourceType('helper', 'helpers', 'Helper');
  • resources.frontController.actionhelperpaths.My_Action_Helper = "My/Action/Helper" 参考link
  • 感谢非常有用的答案:resources.frontController.actionhelperpaths.My_Action_Helper = "My/Action/Helper" 但是,这限制了我只能添加动作助手资源。在引导程序中,我可以拥有:$this-&gt;getResourceLoader()-&gt;addResourceType('customType', 'customResourceFolder', 'CustomPrefix'); 并且我应该能够实例化应该在 APPLICATION_PATH 中定义的$customObj = new Application_CustomPrefix_Hello();。 “customResourceFolder/Hello.php”。这个对象可以是任何东西,不一定是动作助手。
  • 我没有 1:1 的班级名称 |目录路径关系。如果我有,我应该添加一个路径到 include_path 但没有 1:1 等价,我可以使用$this-&gt;getResourceLoader()-&gt;addResourceType('customType', 'customResourceFolder', 'CustomPrefix'); 来访问不遵循 PEAR 命名标准的类。这可以在应用程序ini中完成吗?
  • 我不知道,回答你的问题超出了我的知识范围。对不起!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-06
  • 1970-01-01
  • 1970-01-01
  • 2014-08-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多