Zend Framework tutorial of the MVC Framework for controller usage analysis, zendmvc_php tutorial

Source: Internet
Author: User

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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.