手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表Tag:zf

老王梳理的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文件大致如下:

PHP代码
  1. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap  
  2. {  
  3.     protected function _initAutoloader()  
  4.     {  
  5.         $autoloader = new Zend_Application_Module_Autoloader(array(  
  6.             'namespace' => 'Application',  
  7.             'basePath' => APPLICATION_PATH,  
  8.         ));  
  9.   
  10.         return $autoloader;  
  11.     }  
  12. }  

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

PHP代码
  1. return array(  
  2.     'bootstrap' => array(  
  3.         'path' => APPLICATION_PATH . '/Bootstrap.php',  
  4.     ),  
  5.     'resources' => array(  
  6.         'modules' => array(),  
  7.         'frontController' => array(  
  8.             'controllerDirectory' => APPLICATION_PATH . '/controllers',  
  9.             'moduledirectory' => APPLICATION_PATH . '/modules',  
  10.         ),  
  11.     ),  
  12. );  

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

PHP代码
  1. class Admin_Bootstrap extends Zend_Application_Module_Bootstrap  
  2. {  
  3. }  

需要说明的一点是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的调用,所 以最好在使用时自己扎到源代码里查阅。

Tags: bootstrap, zf

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,这个会给我们带来什么样的惊喜?大文件传输还是其他的?下载源码研究一下,哈哈

Tags: soap, zend framework, zf, framework, dojo

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 :

XML/HTML
  1. Andi Gutmans, the CTO of Zend, blogged yesterday about a new proposal making it’s way through the Zend Framework process.
  2. 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.
  3. 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,

 

XML/HTML代码
  1. 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或许也会主动参与了吧?

Tags: amf, zf, adobe

ZendFramewok介绍

提起Zend,那是在PHP界是相当的有名啊。如果说使用PHP的人居然连Zend也不知道,那是白活了。呵呵

ZendFramework是Zend公司自己推出的一个框架,开发人员都是些元老级人物(但也是有BUG的。。自我安慰一下,高手也会产生BUG),ZF在经历了很长一段时间的发展(大约一年左右吧),才推出1.0系列,现在的版本当然又有了更新

» 阅读全文

Tags: zf, zend, framework