Search code examples
model-view-controllerzend-framework2controllers

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..

I am trying to create a base controller that I can be extended from. I am currently using the Zend Framework 2 skeleton application.

I have created a Resources folder in vendor/zendframework/zendframework/library. Within the the Resources folder, I have a Controllers folder which houses a BaseController.php file.

How do I get my project to autoload the BaseController in the Resources folder for it to be available through out the entire site?

Any help will be most appreciated.

Thanks


Solution

  • 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

    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.

    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