【问题标题】:Zend framework autoload base controller?Zend 框架自动加载基本控制器?
【发布时间】:2010-12-05 16:04:52
【问题描述】:

如何在 Zend 中自动加载基本控制器?

类似:

class Default_AdminUserController extends Application_Component_AdminController{}

只是不起作用 :D 设置和 .ini 中的额外包含路径也不起作用。最好的方法是什么?

【问题讨论】:

    标签: zend-framework controller


    【解决方案1】:

    我知道您的项目结构可能是这样的:

        /zfproject
         /application
           /controller/.............
           /models/................
           /views/.................
           /component   // this is where you want to save your base controller 
           /etc ..............
         /public/...........
         /library/.........
    

    如果我是对的,那么您正在尝试将 ZF 中调用的内容加载为 resource 以及这里的一些例子....http://framework.zend.com/manual/1.11/en/learning.autoloading.resources.html

    基本控制器是一个古老的想法,我在 Cal Evans 的书中阅读了超过 1.5 年:guide to zend framework programming 我强烈建议坚持使用 ZF 插件而不是基本控制器

    【讨论】:

    【解决方案2】:

    为了让这样的类自动加载,它必须被命名:

    [your include path]/Application/Component/AdminController.php

    对于像这样的基类,大多数人通常会在他们的应用程序中拥有一个“库”路径并将其添加到包含路径中,然后遵循 Zend Framework 的命名约定,以便自动加载器正常工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-07
      • 1970-01-01
      • 2011-03-01
      • 1970-01-01
      相关资源
      最近更新 更多