Controller usage Analysis for the MVC framework of the Zend Framework tutorial, ZENDMVC
This article describes the controller usage of the MVC framework for the Zend Framework tutorial. Share to everyone for your reference, as follows:
Here is a brief talk about the basic use of controllers in the MVC pattern.
Basic usage Examples:
root@coder-671t-m:/www/zf_demo1/application# Tree.
├──bootstrap.php
├──configs
│└──application.ini
├──controllers
│├──errorcontroller.php
│└──indexcontroller.php
├──models
└──views
├──helpers
└──scripts
├──error
│└──error.phtml
└──index
└──index.phtml
indexcontroller.php
<?phpclass Indexcontroller extends zend_controller_action{public function init () {/ * Initialize Action Controller here * /} public function indexaction () { //action Body }}
Rules:
1. The controller is usually stored in the/application/controllers directory of the application.
You can customize the path in the following ways:
Zend_controller_front::run ('/path/to/app/controllers ');
Or, customize the path in the following ways:
Set the default controller directory: $front->setcontrollerdirectory ('.. /application/controllers ');//Set several module directories at once: $front->setcontrollerdirectory ( ' Default ' = '. /application/controllers ', ' blog ' = '. /modules/blog/controllers ', ' news ' = '. /modules/news/controllers ',));//Add a ' foo ' module directory: $front->addcontrollerdirectory ('. /modules/foo/controllers ', ' foo ');
By default, it is stored in the default directory.
2. File name and class name are the same
3. The class name ends with a Controller and inherits Zend_controller_action
4. The first letter of the class name is capitalized and follows the hump style. Profit Newslistcontrolle
4. File name ends with controller.php
Initialization of 5.Controller can be done in the Init method
Public Function init () {}
More interested in Zend related content readers can view the topic: "Zend framework of the introductory tutorial", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Tutorial", "PHP object-oriented Programming introduction tutorial "," Introduction to Php+mysql Database Operation "and" PHP common database Operation Skills Summary "
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- Zend Framework Tutorial Autoloading Usage
- Examples of resource autoloading usages of the Zend framework tutorial
- Zend Framework Tutorial's routing function zend_controller_router detailed
- Zend Framework Tutorial Zend_controller_plugin plugin Usage
- Package Zend_controller_response Example of response object for Zend Framework tutorial
- Package Zend_controller_request example of request object for Zend Framework tutorial
- Zend Framework Tutorial Action base class Zend_controller_action detailed
- Zend Framework Tutorial Distributor Zend_controller_dispatcher Usage
- Zend Framework Tutorial Front Controller Zend_controller_front Usage
- Zend Framework Tutorial View component Zend_view Usage
- Zend Framework Tutorial Loader and Pluginloader usage
http://www.bkjia.com/PHPjc/1106888.html www.bkjia.com true http://www.bkjia.com/PHPjc/1106888.html techarticle Zend Framework Tutorial's controller usage analysis of the MVC framework, ZENDMVC This article describes the controller usage of the MVC framework for the Zend Framework tutorial. Share to everyone for your reference, as follows ...