标签:zf

浏览模式: 标准 | 列表 | 图文
老王梳理的Zend Framework Bootstrap机制

老王梳理的Zend Framework Bootstrap机制

以下是老王梳理的内容,bootstrap对于ZF来说非常重要,很大一部分人的程序损耗,都在这里。。。。

原文地址:http://hi.baidu.com/thinkinginlamp/blog/item/419f36d34b68c40a3af3cfc9.html

说点题外话,单就框架而言,对我而言使用CakePHP要比使用Zend Framework顺手得多,不过最近CakePHP陷入了多事之秋,Phpnut,Gwoo,Nate彻底闹僵,Gwoo和Nate选择离开,据坊间传闻他们已经开始另立门户,稍后会释出一个CakePHP的衍生框架:Lithium。虽然CakePHP官方已经表态会一如既往的继续前进,但毫无疑问在众多开发者眼中,CakePHP的前景已经不再明朗,其是否能继续保证PHP框架领头羊的地位也越发充满疑问。

之所以说了这么多题外话,就是为了说明一点,对于广大PHPer而言,过多局限于一种框架之上本身就是一种强耦合,未来是不可预期的。所以我打算在继续使 用CakePHP的同时,适当向Zend Framework倾斜,如果Lithium不错的话,也会在我未来学习计划之中占有一席之地。

言归正传,新版的Zend Framework引入了Zend_Application,把Bootstrap进行的规范化的封装,一个典型的Application的Bootstrap文件大致如下:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoloader()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Application',
'basePath' => APPLICATION_PATH,
));

return $autoloader;
}
}

在Bootstrap中,所有以_init开头的方法被当做资源方法自动运行,如果方法有返回值的话,还会被作为资源保存。资源方法不是唯一配置资源的方 式,为了避免重复编码,框架包含了若干现成的资源插件,可以在配置文件里通过简单设置就可以达到相应的功能,一个典型的配置文件如下所示:

return array(
'bootstrap' => array(
'path' => APPLICATION_PATH . '/Bootstrap.php',
),
'resources' => array(
'modules' => array(),
'frontController' => array(
'controllerDirectory' => APPLICATION_PATH . '/controllers',
'moduledirectory' => APPLICATION_PATH . '/modules',
),
),
);

resources部分的modules和frontController就是资源插件。其中modules资源开启了系统的模块功能。比如说你有一个admin模块的话,那么对应的也可以有一个它自己的Bootstrap类:

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
}

需要说明的一点是Modules的Bootstrap里一般不再需要类似前面的_initAutoloader资源方法,这是因为从父类 Zend_Application_Module_Bootstrap里已经通过继承自动执行了以模块名为命名空间的Autoloader操作。

在使用Modules的Bootstrap时,有一点需要注意的是系统会把所有模块的所有资源方法统统初始化一遍,打个比方来说,如果你有一个Blog模 块,还有一个Forum模块,每个模块使用各自独立的数据库配置,都有一个自己的_initDb方法,那么即便是我们单独访问Blog或者Forum中一 个模块,系统还是会把两个数据库都连接一遍,这无疑是低效的。但也不能就此认为这是Zend Framework的设计错误,问题的根源在于我们划分模块的粒度大小,如上所示,Blog和Forum不应该以Module的形式存在,而应该以 Application的形式存在。如此一来仅需要在Application层次的Bootstrap中执行一次数据库连接即可。

Zend Framework的文档虽然看似详细,但很多细节都没有说明,比如说View助手缺省就会加载,这一点可以在 Zend_Controller_Front中看到对Zend_Controller_Action_Helper_ViewRenderer的调用,所 以最好在使用时自己扎到源代码里查阅。

zendframework 1.6终于将SOAP放进去了

zendframework 1.6终于将SOAP放进去了

1.6版本的zf终于将SOAP放进来了,同时也增加了DOJO的支持。不过我没有想通。为什么那么多的JS框架,最终会选择了DOJO。

这些不是我能够想得通的。还是看看到底更新了什么再说吧。

An overview of new features:

  • Dojo Integration
    • JSON-RPC
    • Dojo Data packing
    • Dojo View Helper
    • Dijit integration with Zend_Form & Zend_View
    • Dojo Library Distribution
  • SOAP
    • SOAP Server
    • SOAP Client
    • Autodiscovery
    • WSDL access
    • WSDL Generation
  • Preview of Tooling Project in Laboratory (see /laboratory folder)
    • Command Line Interface
    • Project Asset Management
  • Unit Testing Harness for Controllers
  • Lucene 2.3 Index File Format Support
  • Zend_Session save handler for Database Tables
  • Paginator Component
  • Text/Figlet Support
  • ReCaptcha Service
  • Zend_Config_Xml Attribute Support
  • Character Set Option for DB Adapters
  • Zend File Transfer Component
  • New Media View Helpers (Flash, Quicktime, Object, and Page)
  • Support in Zend_Translate for INI File Format

This obviously marks a very important step towards a high-quality, highly tested 1.6 GA release. Thanks to everyone who has contributed to this release in any way: with patches/check ins, documentation/translations, and bug reports.

But our work is not yet over! Let's do our best to bring this release to the breaking point to find areas we can improve the release for General Availability. Based on your feedback we will determine in the next few weeks whether we require additional release candidates, so please provide feedback on our issue tracker (http://framework.zend.com/issues) as soon as you can and ask any questions/post your experiences on the appropriate mailing list.

Again, the Zend Framework community does NOT recommend this release for production use. We do, however, recommend evaluating new features in this release with existing and new applications.

Enjoy 1.6RC1, and see you on the issue tracker, wiki, and mailing lists!

————END————

不知道:Zend File Transfer Component,这个会给我们带来什么样的惊喜?大文件传输还是其他的?下载源码研究一下,哈哈

Adobe to contribute AMF support to Zend Framework

Adobe to contribute AMF support to Zend Framework

Copy from framework.zend.com , it's submitted of Thursday, July 31, 2008
It's full contents :

Andi Gutmans, the CTO of Zend, blogged yesterday about a new proposal making it’s way through the Zend Framework process.
Adobe has made a proposal for an AMF (Action Message Format) component in Zend Framework. This ZF component will allow for client-side applications built with Flex and Adobe AIR to communicate easily and efficiently with PHP on the server-side. Leading the design of the component for Adobe is Wade Arnold. Wade already has a track record of bringing the Adobe RIA technologies to PHP as a result of all of his work on AMFPHP.
I know everybody over on the Zend Framework team is real excited about this proposal. If you work with Zend Framework then you are going to want to keep an eye on it.

and someone were comments for this news,

This is really great news! I am currently using JSON as the interface format between my Zend Framework and Flex app. This week I've been considering switching to amfphp (Lee Brimelow prepared a screencast http://www.gotoandlearn.com/player.php?id=78), but I didn't want to refactor/change all of my code. Zend_Amf is great news. I can't wait to begin using it. Cheers Adobe!

这样看来,以后ADOBE或许也会主动参与了吧?

ZendFramewok介绍

3a98d2de71841cd612748baced5a056b

ZF 其实我并不想多做介绍,毕竟对于熟悉PHP的人来说,ZF往往还是被当成研究对象的。官方出品的东西,怎么着都有其优点存在,而且有些类似于MFC中的隐藏函数功能,在ZF里也可能会看到,平时我们不太用、但确实有用的功能,也能够在ZF里面找到。

偷懒一下,直接把framework.zend.com中的whyzf的页面COPY过来,当作ZF的介绍,呵呵。

Why Zend Framework?

Extending the art & spirit of PHP, Zend Framework is based on simplicity, object-oriented best practices, corporate friendly licensing, and a rigorously tested agile codebase. Zend Framework is focused on building more secure, reliable, and modern Web 2.0 applications & web services, and consuming widely available APIs from leading vendors like Google, Amazon, Yahoo!, Flickr, as well as API providers and cataloguers like StrikeIron and ProgrammableWeb.

Expanding on these core themes, we have implemented Zend Framework to embody extreme simplicity & productivity, the latest Web 2.0 features, simple corporate-friendly licensing, and an agile well-tested code base that your enterprise can depend upon.

Extreme Simplicity & Productivity

We designed Zend Framework with simplicity in mind. To provide a lightweight, loosely-coupled component library simplified to provide 4/5s of the functionality everyone needs and that lets you customize the other 20% to meet your specific business needs. By focusing on the most commonly needed functionality, we retain the simplified spirit of PHP programming, dramatically lower the learning curve, and your training costs – so developers get up-to-speed quickly. We do this with:

  • An extensible and well-tested code base – easy to augment
  • A flexible architecture – not locked-in to a rigid application structure
  • No configuration files necessary to get up and running – or when maintaining and deploying your apps

Frameworks and best practices mean reduced training costs and quicker time-to-market – important factors in adoption decisions. Built so you can pick and choose just the pieces you need to turbocharge your web applications – all your developers know where to find their PHP / Zend Framework code, speeding new development and reducing maintenance costs.

Latest Web Development Features

  • AJAX support through JSON – meet the ease-of-use requirements your users have come to expect
  • Search – a native PHP edition of the industry-standard Lucene search engine
  • Syndication – the data formats & easy access to them your Web 2.0 applications need
  • Web Services – Zend Framework aims to be the premier place to consume & publish web services
  • High-quality, object-oriented PHP 5 class library – attention to best practices like design patterns, unit testing, & loose coupling

Friendly & Simple Licensing, Safe for the Enterprise

Based on the simple and safe new BSD license, with Zend Framework's License, you rest assured that your code is compliant, unimpeachable, and protected as you see fit. We also require all contributors to the open source Zend Framework to complete and sign a Contributor License Agreement (CLA) — which is based on the standard open-source Apache license — protecting your own intellectual property (that is, your added-value) built on Zend Framework.

Fully Tested – Extend Safely and Easily

Tested. Thoroughly. Enterprise-ready and built with agile methods, Zend Framework has been unit-tested from the start, with stringent code coverage requirements to ensure that all code contributed has not only been thoroughly unit-tested, but also remains stable and easy for you to extend, re-test with your extensions, and further maintain.