Zend Framework Tutorial: Controller Usage Analysis of MVC Framework
This article describes the use of Controller in the MVC framework of 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 example:
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 } }
Rules:
1. Usually the Controller is 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(array( '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 can be stored in the default directory.
2. The file name is the same as the class name
3. The class name ends with Controller and inherits Zend_Controller_Action
4. The first letter of the class name is capitalized and follows the camel case style. Profit NewsListControlle
4. The file name ends with Controller.php
5. The initialization work of the Controller can be completed in the init method
public function init() { }
Hope this article The above will be helpful to everyone in PHP programming.
For more Zend Framework tutorials and MVC framework Controller usage analysis related articles, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
