Zend Framework教程之MVC框架的Controller用法分析
2016-03-07 00:00
996 查看
本文讲述了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
规则:
1.通常Controller存放在应用的/application/controllers目录下。
可以通过以下方式自定义路径:
或者通过以下方式自定义路径:
默认情况下存放在默认的目录即可。
2.文件名和类名相同
3.类名以Controller结尾,并且继承Zend_Controller_Action
4.类名第一个字母大写,遵守驼峰风格。利润NewsListControlle
4.文件名以Controller.php结尾
5.Controller的初始化工作可以在init方法中完成
更多关于zend相关内容感兴趣的读者可查看本站专题:《Zend FrameWork框架入门教程》、《php优秀开发框架总结》、《Yii框架入门及常用技巧总结》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
Zend Framework教程之Resource Autoloading用法实例
Zend Framework教程之路由功能Zend_Controller_Router详解
Zend Framework教程之Zend_Controller_Plugin插件用法详解
Zend Framework教程之响应对象的封装Zend_Controller_Response实例详解
Zend Framework教程之请求对象的封装Zend_Controller_Request实例详解
Zend Framework教程之动作的基类Zend_Controller_Action详解
Zend Framework教程之分发器Zend_Controller_Dispatcher用法详解
Zend Framework教程之前端控制器Zend_Controller_Front用法详解
Zend Framework教程之视图组件Zend_View用法详解
Zend Framework教程之Loader以及PluginLoader用法详解
这里简单讲讲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 } }
规则:
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结尾,并且继承Zend_Controller_Action
4.类名第一个字母大写,遵守驼峰风格。利润NewsListControlle
4.文件名以Controller.php结尾
5.Controller的初始化工作可以在init方法中完成
public function init() { }
更多关于zend相关内容感兴趣的读者可查看本站专题:《Zend FrameWork框架入门教程》、《php优秀开发框架总结》、《Yii框架入门及常用技巧总结》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
您可能感兴趣的文章:
Zend Framework教程之Autoloading用法详解Zend Framework教程之Resource Autoloading用法实例
Zend Framework教程之路由功能Zend_Controller_Router详解
Zend Framework教程之Zend_Controller_Plugin插件用法详解
Zend Framework教程之响应对象的封装Zend_Controller_Response实例详解
Zend Framework教程之请求对象的封装Zend_Controller_Request实例详解
Zend Framework教程之动作的基类Zend_Controller_Action详解
Zend Framework教程之分发器Zend_Controller_Dispatcher用法详解
Zend Framework教程之前端控制器Zend_Controller_Front用法详解
Zend Framework教程之视图组件Zend_View用法详解
Zend Framework教程之Loader以及PluginLoader用法详解
相关文章推荐
- PHP Echo字符串的连接格式
- 超全局变量$GLOBALS
- Thinkphp下文章管理系统icon图标功能的实现
- php 正确的输出json格式
- PHP htmlspecialchars和htmlspecialchars_decode(函数)
- php添加pcntl扩展
- 如何解决PHP里大量数据循环时内存耗尽的问题
- php 数字格式化输出
- ios php mysql 支持unicode表情 插入问号问题
- php解决跨域请求的三种方法
- PHP创建一个炫酷的图表
- PsySH:PHP交互运行环境
- php使用opendir()与readdir(),还有is_dir()
- PHP中对数组进行操作的常用函数总结
- php中的file_exists函数和filesize函数
- contentprovider用法
- wdcp环境下更新PHP到5.3教程
- PHP-CS-Fixer:格式化你的PHP代码
- IPC机制之使用ContentProvider
- php 反射