`
wonderfan
  • 浏览: 14069 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
社区版块
存档分类
最新评论

Zend Framework

阅读更多
You manually rendered your views by creating a view object,assigning variables,and calling a render() method. The

Zend Framework has a default component called the view renderer,which handles two of these steps for

you:automatically creating a view instance and rendering a view script. The view instance is stored in the controller

instance as $this->view.

The request object encapsulates all the heep data  you could ever want to get your hands on, including all GET,POST

and cookie data. It also provides information parsed from the request uri,such as the controller and action names as

well as a special type of data called parameters,which can be set from the url to make your site more search engine-

friendly than using query variables. Complementing the request object,the respones object provides an encapsulated

way to work with the output stream. Action helpers are resuable classes that add functionality to the controller-

typically,functionality that would not be considered program logic.

The redirector helper does what its name implies:it allows you to redirect the user to a new page. The goto() method

performs the redirection and allows you to redirect to a specific action. The api provided is more desirable than using

headers directly,as there are several factors that can affect a Zend Framework application's url layout down the road.

The FlashMessenger helper is designed to store messages from one request to the next. It allows you to add a

message to be displayed on the next pagem,and it will handle all aspects of the session,including removing the

message from the session after it has been displayed.

View helpers follow the same logic as action helpers,allowing you to create components that are resuable for your

views. Many of the built-in view helpers assist with creating and binding forms to your views. The forms created with

helpers can be slightly wordier than normal. However,they do useful things like output escaping and they will make

creating select drop down lists from an array easier.

Accepting user input in a Zend Framework applications consists of two parts: filtering,which involves the modification

of data,to trim whitespace from the ends of strings or to strip html tags; validation,which occurs after filtering and

ensures that the data is reasonable. Both of these actions can be achieved separately with the Zend_Filter and

Zend_Validate classes.However, they are more commonly used together through the Zend_Filter_Input class,which

is designed to filter arrays of information,such as an entire form or set of url paramters. To use Zend_Filter_Input,you

need to first define two associative arrays: one for your filters and one for your validators.The keys in these arrays

refer to the fields you wish to validate,whereas the values define the rules to apply.

By default,the framework looks for a controller called ErrorController whenever a problem is encountered,instead of

throwing exceptions directly. It also sets a request parameter called error_handler with the request object.This

parameter contains details about the error condition. Front controller is fairly rigid in the url format that controls routing.

By using the rewrite router,you can add routes to the defaults or even override routes completely. The framework has

a number of events that are fired in a class known as the PluginBroker,technically

Zend_Controller_Plugin_Broker,which is a basic registration and notification class. These events allow you an

opportunity to interact and disrupt the dispatching process. Typically, this disruption will be in the form of changing

values in Zend_Request that will have effects down the road. Writing your own plug-ins is fairly simple.First ,all plug-

ins must subclass Zend_Controller_Plugin_Abstract and may implement any of the PluginBroker methods. Zend_Acl

is a powerful but decidedly confusing component that allows you to define the actions that a suer is authorized to take

on your web site. While Zend_Acl can be used imdepently of plug-ins and helpers,it is far more powerful as a

complete solution. It is a robust access system consisting of an inherited role assignment with both resource and

permission -level controls.

As with resources,creating a role is also very simple. All roles must implement Zend_Acl_Role_Interface. This

interface consists of a single method,getRoleId(),Addtionally,Zend_Acl_Role is provided by Zend_Acl as a basic role

implementation.

Zend_Auth is concerned only with authentication and not with authorization. Authentication is loosely defined as

determining whether an entityt actually is what it purprots to be based on some set of credentials. A Zend_Auth

adapter is used to authenticate against a particular type of authentication service such as ldap,rdbms or file -based

storage. Different adapters are likely to have vastly different options and behaviors,but some basic things are

common among authentication adapters. Each Zend_Auth adapter class implements Zend_Auth_Adapter_Interface.

This interface defines one method,authenticate(),that an adapter class must implement for performing an

authentication query.Each adapterclass must be prepared prior to calling authenticate(). Such adapter preparation

includes setting up credentials and defining values for adapter-specific configuration options,such as database

connection settings for a database table adapater.

Zend_Auth_Adapter_DbTable provides the ablity to authenticate against credentials stored in a database table. Zend

Framework includes serveral action helpers by default: AutoComplete for automating response for ajax

autocompletion;ContextSwitch  and AjaxContext for serving alternate response formats for your actions; a

FlashMessenger for handling session flash messages;Json foe encoding and send json response; a Redirector ,to

provide different implementation for redirecting to internal and external pages from your application; and a

ViewRenderer to automate the process of setting up the view object in your controllers and rendering views. 

The ViewRenderer helper is designed to satisfy the following goals: eliminate the need to instantiate view object

within controllers,view object will be automatically registered with the controller; automatically set view

script,helper,and filter paths based on the current module,and automatically associate the current module name as a

class prefix for helper and filter classes; create a globally available view object for all dispatched controllers and

actions. The front controller will pass any caught exceptions to the reponse object,allowing the developer to gracefullt

handle exception. Zend_Controller_Front and Zend_Controller_Route_Route_Module were each using methods of

the dispatcher that were not in the dispatcher interface. 

Zend_Db_Profiler can be enabled to allow profiling of queries. Profiles include the queries processed by the adapter

as well as elapsed time to run the queries,allowing inspection of the queries that have been performed without

needing to add extra debugging code to classed. The Zend_Db_Table class is an object-oriented interface to

database tables. It provides methods for many common operations on tables. By default, method of the table class

retrun a Rowset in instance of the concrete class Zend_Db_Table_Rowset and Rowsets contain a collection of

instance of the concrete class Zend_Db_Table_Row. You can specify row and rowset classes using the table

constructor's options array,in keys rowClass and rowsetClass respectively.

You can specify the database table name independently from the class name by declaring the table name with the

$_name class property in each of your table classes.  Zend_Db_Table_Abstract performs no infkection to map the

class name to the table name. If you omit the declaration of $_name in your table class,the class maps to a dtabase

table that matches the spelling tof the class name exactly. 

Rendering a form in a view script is as simple as <?= $this->form ?>. Under the hood, Zend_Form uses decorators to

perform rendering. These decorators can replace content,append  content,or precond content,and have full

introspection to the element passed to them. Zend_Form_Element tries to solve this issue through the use of

decorators. Decorators are simply classes that have access to the element and a method for rendering content. The

file form element provides a mechanism for supplying file upload fields to your form. It utilizes Zend_File_Transfer

internally to provide this functionality,and the FormFile view helper to display the form element.

By default, it uses the http transfer adapter which introspects the $_FILES array and allows yopu to attach validators

and filters. Validators and filters attached to the form element will be attached to the transfer adapter.

The Zend_Loader methods are best used if the filename you need to load is variable.Zend_URI is a component that

aids in manipulating and validating uniform resource identifiers. Zend_Uri exists primarily to service other components

such as Zend_Http_Client but is also useful as a standalone utility.The Zend-Uri class provides a factory that returns a

subclass of itself which specializes in each scheme.The subclass will be named Zend_Uri_<scheme>. If your

application requires even greater flexibility with which it reports validation failures,you can access properties by the

same name as the message token supported by a given validation class. If it is inconvenient to load a given validation

class and create an instance of the validator,you can use the static method Zend-Validate::is() as an alternative

invocation style. The first atgument of this method is a data input value ,that you would pass to the isValid() method.

The second argument ios a string,which corresponds to the basename of the validation class,reative to the

Zend_Validate namespace. Zeend_Validate supplies a set of commonly needed validators,but inevitably,developers

will wish to write custom validatios for their particular needs. Zend_Validate_Interface defines three methods, isValid

(),getMessage() and getErrors(),that may be implemented by user classes in order to create custom validation

objects. An object that implements Zend_Validate_Interface interface may be added to a validator chain with

Zend_Validate::addValidator().

Zend_View is a class for working with the view portion of the model-view-controller pattern. That is, it exists to help

keep the view script separate from the model and controller script. It provides a system of helpers,output filters and

variable escaping. Zend_View is a template system agnostic; Essectially, using Zend-View happens in two major

steps:1.your controller script creates an instance of Zend_View and assigns variables to that instance.2. The

controller tells the Zend_View to render a particular view,thereby handing control over the view script,which generates

the view output. By default,Zend_View expects your view script to be relative to your calling script. Zend_View comes

with an initial set of helper classes,most of which relate to form element generation and perfom the appropriate output

escaping automatically. The action view helper enables view script to dispatch a given controller action.
分享到:
评论

相关推荐

    zend framework中英文手册.rar

    **Zend Framework 中英文手册** **一、Zend Framework 简介** Zend Framework 是一个开源的、基于组件的 PHP 框架,旨在提供高效的开发环境,以构建高质量的Web应用程序。它遵循MVC(Model-View-Controller)设计...

    ZendFramework-1.10.4-minimal

    "ZendFramework-1.10.4-minimal" 这个标题表明我们正在处理的是 Zend Framework 的一个特定版本,即1.10.4,并且是精简版(minimal)。这意味着它可能包含了框架的核心组件,但可能去除了某些非必要的或附加的模块,...

    Zend Framework 2 Application Development

    Whether you are learning Zend framework from scratch or looking to sharpen up your skills from previous versions, Zend Framework 2 Application Development will help you to harness the power of Zend ...

    ZEND FRAMEWORK 1.11.7 中文参考文档

    Table of Contents •Introduction to Zend Framework •Overview •Installation •Learning Zend Framework •Zend Framework Quick Start •Autoloading in Zend Framework •Plugins in Zend Framework •...

    基于Zend Framework 框架的CMS PHP 源代码

    Zend Framework推崇“选择性使用”原则,开发者可以根据项目需求选择使用其中的部分或全部组件,极大地提高了开发效率和代码质量。 **二、CMS系统的核心功能** CMS系统通常包含以下核心功能: 1. **内容创建与...

    ZendFramework 1.12.9 代码和文档.rar

    1. **下载与解压**:首先,从官方网站或者提供的压缩包"ZendFramework-1.12.9.zip"下载并解压到服务器的适当位置。 2. **环境要求**:确保服务器环境满足PHP 5.2.5或更高版本。 3. **配置自动加载**:通过设置`...

    zend framework 中文手册

    描述提到"zend framework zendframework manual 手册,Zend Framework手册 中文版,有一部分还没有汉化",这意味着虽然该手册是中文版本,但可能并非全部内容都已翻译完成,部分原文可能是英文状态。 **Zend ...

    Zend Framework+smarty用法实例详解

    在Zend Framework中整合Smarty模板引擎,可以让开发人员利用Zend Framework强大的框架特性和Smarty简洁的模板语法来创建更为复杂和功能丰富的Web应用。以下是整合Zend Framework与Smarty时需要了解的相关知识点。 ...

    Zend Framework 2 官方教程汉化版

    Zend Framework 2 官方教程汉化版

    Zend Framework 中文 手册 入门教程

    Zend Framework 中文 手册 2008年12月01日.chm MD5: DD29C39D12E9C0B38FD3475A12D05B73 SHA1: 1A6BBBF9311013F2FF2BF97752332160ED767526 CRC32: 88210ABD Zend Framework 入门教程(简体中文1.52版)v0.12.pdf MD5:...

    ZendFramework中文文档

    1. Introduction to Zend Framework 1.1. 概述 1.2. 安装 2. Zend_Acl 2.1. 简介 2.1.1. 关于资源(Resource) 2.1.2. 关于角色(Role) 2.1.3. 创建访问控制列表(ACL) 2.1.4. 注册角色(Role) 2.1.5. 定义访问...

    Zend Framework实例教程

    - 命令行下载:使用`wget`命令下载,例如:`$ wget http://framework.zend.com/download/tgz`,接着解压:`$ tar -xvzf ZendFramework-0.1.2.tar.gz`。 ##### 目录结构: - 将下载的`library`目录重命名并放置于...

    Zend Framework教程之Zend_Layout布局助手详解

    Zend Framework教程之Zend_Layout布局助手详解重点介绍了Zend Framework中Zend_Layout组件的使用方法。Zend_Layout是一个用于管理布局的组件,它允许开发者定义应用程序的布局结构,使得可以在不同的页面中复用相同...

    zend framework 中文版手册(最新)

    **Zend Framework 中文版手册详解** Zend Framework 是一个开源、基于组件的 PHP 框架,旨在加速 web 应用程序的开发。它遵循“敏捷软件开发”原则,提供了丰富的库,支持MVC(Model-View-Controller)模式,使得...

    zend framework2例子album 完整能运行

    Zend Framework 2(ZF2)是一个面向对象的、模块化且高性能的PHP开发框架,用于构建Web应用程序和服务。本示例“album”是ZF2官方提供的一个基础教程项目,旨在帮助开发者快速理解和学习如何在ZF2中进行实际的开发...

    ZendFramework中文手册HTML版

    Zend Framework 遵循 Model-View-Controller (MVC) 设计模式,它将应用程序的业务逻辑、数据和用户界面分离开来,使得代码更易于维护和扩展。在 MVC 架构中,Model 负责处理业务逻辑,View 负责展示数据,而 ...

    ZendFramework最新版本

    这个“最新版本”指的是 Zend Framework 的 1.11.10 版本,它包含了 MVC(Model-View-Controller)架构模式,这是 Web 开发中常用的设计模式,用于分离应用程序的不同部分,提升代码的可读性和可维护性。 1. **MVC ...

    zend framework教程.zip

    **Zend Framework 框架详解** Zend Framework 是一个基于组件的 PHP 开发框架,由 Zend Technologies 公司创建并维护,被PHP官网推荐为MVC(Model-View-Controller)框架之一,尤其适合构建企业级的Web应用。本教程...

Global site tag (gtag.js) - Google Analytics