Zend Framework 入门
程序员文章站
2024-02-02 22:02:40
...
一.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 = 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文件夹。