Table of Contents
Analysis of the Controller usage of the MVC framework in the Zend Framework tutorial, zendmvc
Articles you may be interested in:
Home Backend Development PHP Tutorial Analysis of Controller usage of MVC framework in Zend Framework tutorial, zendmvc_PHP tutorial

Analysis of Controller usage of MVC framework in Zend Framework tutorial, zendmvc_PHP tutorial

Jul 12, 2016 am 08:57 AM
controller framework mvc zend

Analysis of the Controller usage of the MVC framework in the Zend Framework tutorial, zendmvc

This article describes the Controller usage of the MVC framework in the Zend Framework tutorial. Share it with everyone for your reference, the details are as follows:

Here is a brief introduction to the basic use of Controller in the MVC model.

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

<?php
class IndexController extends Zend_Controller_Action
{
  public function init()
  {
    /* Initialize action controller here */
  }
  public function indexAction()
  {
    // action body
  }
}

Copy after login

Rules:

1. Usually Controller is stored in the /application/controllers directory of the application.
The path can be customized via:

Zend_Controller_Front::run('/path/to/app/controllers');
Copy after login

Or customize the path via:

// Set the default controller directory:
$front->setControllerDirectory('../application/controllers');
// Set several module directories at once:
$front->setControllerDirectory(array(
  'default' => '../application/controllers',
  'blog'  => '../modules/blog/controllers',
  'news'  => '../modules/news/controllers',
));
// Add a 'foo' module directory:
$front->addControllerDirectory('../modules/foo/controllers', 'foo');

Copy after login

By default, it can be stored in the default directory.

2. The file name and class name are the same
3. The class name ends with Controller and inherits Zend_Controller_Action
4. Capitalize the first letter of the class name and follow the camel case style. ProfitNewsListControlle
4. The file name ends with Controller.php
5. The initialization work of Controller can be completed in the init method

public function init()
{
}

Copy after login

Readers who are interested in more zend-related content can check out the special topics of this site: "Zend FrameWork Framework Introductory Tutorial", "php Excellent Development Framework Summary", "Yii Framework Introduction and Summary of Common Techniques", "ThinkPHP Introductory Tutorial" , "php object-oriented programming introductory tutorial", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • Detailed explanation of Autoloading usage in Zend Framework tutorial
  • Resource Autoloading usage example in Zend Framework tutorial
  • Zend Framework tutorial Detailed explanation of routing function Zend_Controller_Router
  • Zend Framework tutorial: Detailed explanation of Zend_Controller_Plugin plug-in usage
  • Zend Framework tutorial: Encapsulation of response object, detailed explanation of Zend_Controller_Response instance
  • Zend Framework tutorial: Encapsulation of request object, Zend_Controller_Request Detailed explanation of examples
  • Detailed explanation of the base class Zend_Controller_Action of action in Zend Framework tutorial
  • Detailed explanation of usage of Zend Framework tutorial’s distributor Zend_Controller_Dispatcher
  • Zend Framework tutorial detailed explanation of usage of front-end controller Zend_Controller_Front
  • Detailed explanation of usage of view component Zend_View in Zend Framework tutorial
  • Detailed explanation of usage of Loader and PluginLoader in Zend Framework tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1106888.htmlTechArticle Analysis of the Controller usage of the MVC framework in the Zend Framework tutorial, zendmvc This article describes the Controller usage of the MVC framework in the Zend Framework tutorial . Share it with everyone for your reference, the details are as follows...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Microsoft NET Framework Installation Issues Error Code 0x800c0006 Fix Microsoft NET Framework Installation Issues Error Code 0x800c0006 Fix May 05, 2023 pm 04:01 PM

Microsoft NET Framework Installation Issues Error Code 0x800c0006 Fix

How to solve the problem that SpringBoot cannot scan the Controller How to solve the problem that SpringBoot cannot scan the Controller May 14, 2023 am 08:10 AM

How to solve the problem that SpringBoot cannot scan the Controller

How to identify Windows upgrade issues using SetupDiag on Windows 11/10 How to identify Windows upgrade issues using SetupDiag on Windows 11/10 Apr 17, 2023 am 10:07 AM

How to identify Windows upgrade issues using SetupDiag on Windows 11/10

SCNotification has stopped working [5 steps to fix it] SCNotification has stopped working [5 steps to fix it] May 17, 2023 pm 09:35 PM

SCNotification has stopped working [5 steps to fix it]

Microsoft .NET Framework 4.5.2, 4.6, and 4.6.1 will end support in April 2022 Microsoft .NET Framework 4.5.2, 4.6, and 4.6.1 will end support in April 2022 Apr 17, 2023 pm 02:25 PM

Microsoft .NET Framework 4.5.2, 4.6, and 4.6.1 will end support in April 2022

PHP MVC Architecture: Building Web Applications for the Future PHP MVC Architecture: Building Web Applications for the Future Mar 03, 2024 am 09:01 AM

PHP MVC Architecture: Building Web Applications for the Future

How to add URL prefix to SpringBoot multiple controllers How to add URL prefix to SpringBoot multiple controllers May 12, 2023 pm 06:37 PM

How to add URL prefix to SpringBoot multiple controllers

KB5012643 for Windows 11 breaks .NET Framework 3.5 apps KB5012643 for Windows 11 breaks .NET Framework 3.5 apps May 09, 2023 pm 01:07 PM

KB5012643 for Windows 11 breaks .NET Framework 3.5 apps

See all articles