首页 / PHP / ZendFramework入门
ZendFramework入门
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ZendFramework入门,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3144字,纯文字阅读大概需要5分钟。
内容图文
![ZendFramework入门](/upload/InfoBanner/zyjiaocheng/156/c64580aed6de493ba19494f9bb9d7b8f.jpg)
详细请看这篇文章:
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 = 0 phpSettings.display_errors = 0 includePaths.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 = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1
四.Action Controllers
一个controller应该有一个或者多个methods,这些methods可以通过浏览器被请求。通常可以写一个indexcontroller,作为站点的主页。
默认的indexcontroller为下:
// application/controllers/IndexController.php class 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文件夹。
<spanMicrosoft YaHei'; color:rgb(255,102,102)">七. 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 入门,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
内容总结
以上是互联网集市为您收集整理的ZendFramework入门全部内容,希望文章能够帮你解决ZendFramework入门所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。