Zend Framework教程之MVC框架的Controller用法分析
本文講述了Zend Framework教程之MVC框架的Controller用法。分享給大家供大家參考,具體如下:
這里簡單講講MVC模式中Controller的基本使用方法。
基本使用實例:
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
}
}
規(guī)則:
1.通常Controller存放在應用的/application/controllers目錄下。
可以通過以下方式自定義路徑:
Zend_Controller_Front::run('/path/to/app/controllers');
或者通過以下方式自定義路徑:
// 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');
默認情況下存放在默認的目錄即可。
2.文件名和類名相同
3.類名以Controller結(jié)尾,并且繼承Zend_Controller_Action
4.類名第一個字母大寫,遵守駝峰風格。利潤NewsListControlle
4.文件名以Controller.php結(jié)尾
5.Controller的初始化工作可以在init方法中完成
public function init()
{
}
更多關(guān)于zend相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Zend FrameWork框架入門教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《Yii框架入門及常用技巧總結(jié)》、《ThinkPHP入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家PHP程序設(shè)計有所幫助。
- Zend Framework連接Mysql數(shù)據(jù)庫實例分析
- 解析如何使用Zend Framework 連接數(shù)據(jù)庫
- zend framework配置操作數(shù)據(jù)庫實例分析
- Zend Framework框架教程之Zend_Db_Table_Rowset用法實例分析
- Zend Framework教程之Zend_Db_Table_Row用法實例分析
- Zend Framework教程之Zend_Db_Table用法詳解
- Zend Framework入門知識點小結(jié)
- Zend Framework緩存Cache用法簡單實例
- Zend Framework基本頁面布局分析
- Zend Framework教程之配置文件application.ini解析
- Zend Framework教程之Loader以及PluginLoader用法詳解
- Zend Framework教程之連接數(shù)據(jù)庫并執(zhí)行增刪查的方法(附demo源碼下載)
相關(guān)文章
php同時使用session和cookie來保存用戶登錄信息的實現(xiàn)代碼
下面小編就為大家?guī)硪黄猵hp同時使用session和cookie來保存用戶登錄信息的實現(xiàn)代碼。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考,一起跟隨小編過來看看吧2016-05-05
php使用CURL模擬GET與POST向微信接口提交及獲取數(shù)據(jù)的方法
這篇文章主要介紹了php使用CURL模擬GET與POST向微信接口提交及獲取數(shù)據(jù)的方法,結(jié)合實例形式分析了php使用curl向微信接口提交與獲取相關(guān)數(shù)據(jù)的操作技巧,需要的朋友可以參考下2016-09-09
PHP實現(xiàn)的帶超時功能get_headers函數(shù)
這篇文章主要介紹了PHP實現(xiàn)的帶超時功能的get_headers函數(shù),本文直接給出實現(xiàn)代碼,需要的朋友可以參考下2015-02-02
Laravel框架模型的創(chuàng)建及模型對數(shù)據(jù)操作示例
這篇文章主要介紹了Laravel框架模型的創(chuàng)建及模型對數(shù)據(jù)操作,結(jié)合實例形式分析了Laravel框架創(chuàng)建模型及使用模型進行數(shù)據(jù)的增刪改查等相關(guān)操作技巧,需要的朋友可以參考下2019-05-05
php基于Redis消息隊列實現(xiàn)的消息推送的方法
這篇文章主要介紹了php基于Redis消息隊列實現(xiàn)的消息推送的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-11-11

