简体   繁体   English

基本控制器zend framework 2

[英]base controller zend framework 2

I wonder if someone here can help, I am just starting with Zend Framework 2 and I am find it slightly daunting to get a project started off properly.. 我不知道这里是否有人可以帮忙,我只是从Zend Framework 2开始,而我发现要正确启动一个项目有点令人生畏。

I am trying to create a base controller that I can be extended from. 我正在尝试创建一个可以扩展的基础控制器。 I am currently using the Zend Framework 2 skeleton application. 我当前正在使用Zend Framework 2骨架应用程序。

I have created a Resources folder in vendor/zendframework/zendframework/library. 我在vendor / zendframework / zendframework / library中创建了一个Resources文件夹。 Within the the Resources folder, I have a Controllers folder which houses a BaseController.php file. 在Resources文件夹中,我有一个Controllers文件夹,其中包含BaseController.php文件。

How do I get my project to autoload the BaseController in the Resources folder for it to be available through out the entire site? 我如何使我的项目自动将Resources文件夹中的BaseController加载到整个站点中?

Any help will be most appreciated. 任何帮助将不胜感激。

Thanks 谢谢

You shouldn't need to create a base controller, ZF2 already provides a number of base controllers for you, such as the RestController and the AbstractActionController 您不需要创建基本控制器,ZF2已经为您提供了许多基本控制器,例如RestController和AbstractActionController

http://framework.zend.com/manual/2.0/en/modules/zend.mvc.controllers.html http://framework.zend.com/manual/2.0/en/modules/zend.mvc.controllers.html

If you are going to create a base controller, create you own module and put it in the vendors directory. 如果要创建基本控制器,请创建您自己的模块并将其放在vendor目录中。

You should never need to go into third party modules and modify code as you should be able to inherit and extend the classes that are provided by such libraries 您永远不需要进入第三方模块并修改代码,因为您应该能够继承和扩展此类库提供的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM