文档章节

A Practical Tutorial Of Zend Framework(一)

Donald Yang
 Donald Yang
发布于 2016/06/20 19:13
字数 636
阅读 8
收藏 0

The Zend Framework has been unveiled! Although it is still in the early stages of development, this tutorial highlights some of the best of what's available now and guides you through the process of building a simple application.

Zend has chosen to release the framework and involve the community early. In the same spirit, this tutorial is written to showcase the framework as it exists today. Because this tutorial is published online, I'll update it as the framework evolves, so that it remains relevant as long as possible.

Requirements

The Zend Framework requires PHP 5. In order to take full advantage of the code presented in this tutorial, you also need the Apache web server, because the sample application (a news management system) uses mod_rewrite. The code from this tutorial is available for free download, so you can try it out for yourself. You can download it from the Brain Bulb web site at http://brainbulb.com/zend-framework-tutorial.tar.gz.

Downloading the Framework

Before you can get started with this tutorial, you need to download the preview release of the framework. You can do this manually by visiting http://framework.zend.com/download with a browser and choosing the tar.gz or zip download, or you can use the command line:
$ wget http://framework.zend.com/download/tgz
$ tar -xvzf ZendFramework-0.1.2.tar.gz
Note: Zend has plans to offer its own PEAR channel to help simplify the download process.
Once you have the preview release, locate the library directory and place it somewhere convenient. In this tutorial, I rename library to lib to provide a clean and simple directory structure:
app/
    views/
    controllers/
www/
    .htaccess
    index.php
lib/
The www directory is the document root, controllers and views are empty directories you'll use later, and the lib directory is from the preview release download.

Getting Started

The first component I want to show you is Zend_Controller. In many ways, it provides the foundation of the application you're developing, and it's also part of what makes the Zend Framework more than just a collection of components. Before you can use it, however, you need to direct all incoming requests to a single PHP script. This tutorial uses mod_rewrite for this purpose. Using mod_rewrite is an art in itself, but luckily, this particular task is very simple. If you're unfamiliar with mod_rewrite or configuring Apache in general, create a .htaccess file in the document root and add the following directives:
RewriteEngine on
RewriteRule !/.(js|ico|gif|jpg|png|css)$ index.php
Note: One of the TODO items for Zend_Controller is to remove the mod_rewrite dependency. In order to provide an example that works with the preview release, this tutorial uses mod_rewrite.
If you add these directives to httpd.conf directly, you must restart the web server. Otherwise, if you use a .htaccess file, you should be good to go. You can quickly test this by placing some identifiable text in index.php and making a request for an arbitrary path such as /foo/bar. For example, if your host is example.org, request the URL http://example.org/foo/bar. You also want include_path to include the path to the framework library. You can do this in php.ini, or you can just put the following directive in your .htaccess file: php_value include_path "/path/to/lib"

Zend

The Zend class contains a collection of static methods that are universally useful. This is the only class you must include manually:
<?php

include 'Zend.php';

?>
Once you've included Zend.php, you have access to all of the methods from the Zend class. Loading other classes is simplified with the loadClass() method. For example, to load the Zend_Controller_Front class:
<?php

include 'Zend.php';

Zend::loadClass('Zend_Controller_Front');

?>
The loadclass() method is include_path aware, and it also understands the organization and directory structure of the framework. I use it to load all other classes.

本文转载自:http://blog.csdn.net/ffyd2000/article/details/668057

Donald Yang
粉丝 2
博文 56
码字总数 139
作品 0
成都
私信 提问
菜菜鸟Zend Framework 2 不完全学习涂鸦(一)-- 安装配置

声明:本人 PHPer 菜鸟一枚,Zend Framework 2 框架的菜菜鸟,刚学习 ZF2 不过 2 天。由于英语实在太破,所以一开始只能找网上 ZF2 中文教程,但很多教程都只说到 ZF2 安装与配置就结束了,没...

Jacky.Wang
2013/07/18
23.3K
27
世界500强企业招聘php开发人员

Job description 1. Maintain, Develop, implement and test server-side and front-end PHP-based applications 2. Maintain, Develop, implement Java applications 3. Provide technical ......

时海连camilla
2011/12/21
394
5
《Zend Framework 2 程序员参考指南》 一、概述 Overview

Zend Framework 2是一个使用PHP 5.3+(含以上版本)开发WEB应用程序和服务的开放源代码的框架(framework)。Zend Framework 2使用100%的面相对象代码,并且利用了大部分PHP5.3 的新功能,命...

v8v9v3000
2013/10/03
0
0
菜菜鸟Zend Framework 2 不完全学习涂鸦(十四)-- 单元测试一个ZF2应用程序

单元测试一个Zend Framework 2应用程序 在一个大型项目的开发过程中特别是牵涉到许多人员参与时,一个可靠的单元测试是必不可少的。对于应用程序每当有所变化后都返回并手动对每个组件进行测...

Jacky.Wang
2013/08/23
3.4K
1
PHP沉思录-第四篇-Zend Framework-左轻侯-《程序员》2007年12月号

本文发表于《程序员》杂志2007年第12期,略有删节。      PHP沉思录之四:Zend Framework   左轻侯   2007.11.11       从理论上来说,PHP是一种通用的动态语言,它可以替代Per...

一配
2015/10/16
34
0

没有更多内容

加载失败,请刷新页面

加载更多

CSS--列表

一、列表标识项 list-style-type none:去掉标识项 disc:默认实心圆 circle:空心圆 squire:矩形 二、列表项图片 list-style-img: 取值:url(路径) 三、列表项位置 list-style-position:...

wytao1995
今天
6
0
linux 命令-文本比较comm、diff、patch

本文原创首发于公众号:编程三分钟 今天学了三个文本比较的命令分享给大家。 comm comm 命令比较相同的文本 $ cat charabc$ cat chardiffadc 比如,我有两个文件char和chardiff如上,...

编程三分钟
今天
7
0
QML教程

https://blog.csdn.net/qq_40194498/article/category/7580030 https://blog.csdn.net/LaineGates/article/details/50887765...

shzwork
今天
5
0
HA Cluster之5

对于使用heartbeat v2版的CRM配置的集群信息都是保存在一个名为cib.xml的配置文件中,存放在/var/lib/heartbeat/crm/下。CIB:Cluster Information Base,由于xml文件配置不是那么方便,所以...

lhdzw
今天
6
0
玩转Redis-Redis基础数据结构及核心命令

  《玩转Redis》系列文章主要讲述Redis的基础及中高级应用,文章基于Redis5.0.4+。本文主要讲述Redis的数据结构String,《玩转Redis-Redis基础数据结构及核心命令》相关操作命令为方便对比...

zxiaofan666
今天
11
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部