Zend Framework 入门
来源:互联网 发布:java getberlength 编辑:程序博客网 时间:2024/05/16 14:27
一.Create YourProject
详细请看这篇文章:
http://blog.csdn.net/u012675743/article/details/45511019
二.The BootStrap
Bootstrap用来定义你的项目资源和组件初始化。类如下:
//application/Bootstrap.php class Bootstrapextends Zend_Application_Bootstrap_Bootstrap{}
详细还可以参考这篇文章:
http://blog.csdn.net/u012675743/article/details/45510903
三.Configuration
经常需要自己配置应用,默认配置文件在application/configs/application.ini
,
其中也包含了指令用来设置PHP环境,声明bootstrap路径,
; application/configs/application.ini[production]phpSettings.display_startup_errors = 0phpSettings.display_errors = 0includePaths.library = APPLICATION_PATH "/../library"bootstrap.path = APPLICATION_PATH "/Bootstrap.php"bootstrap.class = "Bootstrap"resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"[staging : production][testing : production]phpSettings.display_startup_errors = 1phpSettings.display_errors = 1[development : production]phpSettings.display_startup_errors = 1phpSettings.display_errors = 1
四.Action Controllers
一个controller应该有一个或者多个methods,这些methods可以通过浏览器被请求。通常可以写一个indexcontroller,作为站点的主页。
默认的indexcontroller为下:
// application/controllers/IndexController.phpclass IndexController extends Zend_Controller_Action{ public function init() { /* Initialize action controller here */ } public function indexAction() { // action body }}
五.Views
每个controller都在application/views/scripts/下有一个对应的视图。并相应的命名为 ‘controller/controller.phtml’,主要写前台要展示的页面。
六.Create A Layout
在命令行下输入:
记得一定要切换到工程文件夹下,否则会出现如下提示:
然后打开layouts文件夹下,会出现一个scripts文件夹。
七. Create a Model andDatabase Table
对数据库中要操作的每一个表都需要写一个表类,$_primary为表的主键,例如:
<?php class Book extends Zend_Db_Table{ protected $_name = 'book'; protected $_primary = 'id';}
八. Create A Form
使用框架的form来提交数据的入口是非常方便的。在application下创建目录forms,即application/forms,并创建相应的form class。
例如:
<?php class Application_Form_Guestbook extendsZend_Form{ public function init() { // Set the method for the display form to POST $this->setMethod('post'); // Add an email element $this->addElement('text', 'email', array( 'label' => 'Your emailaddress:', 'required' => true, 'filters' =>array('StringTrim'), 'validators' => array( 'EmailAddress', ) )); // Add the comment element $this->addElement('textarea', 'comment', array( 'label' => 'PleaseComment:', 'required' => true, 'validators' => array( array('validator' =>'StringLength', 'options' => array(0, 20)) ) )); // Add a captcha $this->addElement('captcha', 'captcha', array( 'label' => 'Please enterthe 5 letters displayed below:', 'required' => true, 'captcha' => array( 'captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 300 ) )); // Add the submit button $this->addElement('submit', 'submit', array( 'ignore' => true, 'label' => 'Sign Guestbook', )); // And finally add some CSRF protection $this->addElement('hash', 'csrf', array( 'ignore' => true, )); }}
- Zend Framework-Zend_Controller入门
- Zend Framework入门指引
- Zend Framework入门指引
- Zend Framework入门
- Zend Framework入门教材
- 菜鸟入门zend framework;
- zend framework入门(1)
- zend framework入门2
- zend framework入门3
- Zend Framework 入门
- php之zend framework入门
- Zend Framework教程-入门相关
- zend framework 入门好文章
- Zend Framework教程-入门相关
- Zend Framework单表CRUD入门示例
- Zend Framework 入门——错误处理
- Zend Framework 2 入门-视图(View)
- Zend Framework 2 入门-数据分页-pagination
- 系统操作日志设计
- 银行取款机c++实现
- 关于JSP源码泄漏问题的总结分析
- 探索React生态圈
- idea自动生成serialVersionUID
- Zend Framework 入门
- tomcat学习(1)
- 浅谈管理系统操作日志设计(附操作日志类)
- 在业务中找痛点
- Linked List Cycle
- HDU 1159(Common Subsequence)最长公共子序列
- C++中随机函数rand()和srand()的用法
- CentOS7.0部署Docker
- Log4j最佳实践