Zend Framework前瞻(二):0.2.0的新变化

本文内容已经不能适应当前 Zend Framework 版本(0.9+),请参阅更新的文章。20070407

0.2.0增加了以下内容

Zend_Cache
以文件,sqlite数据库或memcache为后端,通过ID和tag来标示数据,可以设定过期期限(以秒为单位),可以自动序列化(因此可以缓存任何数据)。
Zend_Cache类本身是一个工厂类,可以定制cache内容(前端)为Output,File,Function 和 Class。
不过,你可以用Zend_Cache_Core作为统一的访问方式。以下是一个官方手册的例子

require_once 'Zend/Cache.php';
$frontendOptions = array( 'lifeTime' => 7200,
           // cache lifetime of 2 hours
           'automaticSerialization' => true);
$backendOptions = array( 'cacheDir' => './tmp/'
  
 // Directory where to put the cache files);
    // getting a Zend_Cache_Core object
$cache =
Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);

更多说明在此
http://framework.zend.com/manual/en/zend.cache.html
需要注意的是不同缓存的 id 不能重复,否则会有串扰,lol

Zend_Config
专门用于存储在文本中的配置处理
由 Zend_Config_Array,Zend_Config_Ini 和 Zend_Config_Xml 这三个有共同 父类 Zend_Config 的子类组成
ini 和 xml 可能用得会多点
看看官方例子就知道怎么用了
http://framework.zend.com/manual/en/zend.config.html
不过,这些类不是用来保存配置
Zend 官方说保存配置这件事情不归 ZF 管

Zend_Feed
现在用不着什么 lastRSS 之类的 homemade产品了
Zend_Feed_RSS 和 Zend_Feed_Atom ……或者就用 Zend_Feed 就可以帮你解析 feed
从网页中找到rss feed,修改节点内容,还可以输出为xml…… ZF 官方站点的rss feed就是用Zend_Feed 输出的
解析 feed 最简单
$feed = Zend_Feed::import($url);
…Zend_Feed::importFile($filename);
…Zend_Feed::importString($feedstring);
然后就rss内容就在$feed里了

Zend Google Data Client Library
与一系列 Google 服务交互的 APIs
Google Base, Calendar, Blogger, and CodeSearch 等等
这部分需要单独下载
http://framework.zend.com/download/gdata

其他还有 Zend_Acl, Zend_Registry, Zend_Session 等
但还未进入 stable 的状态,暂时不介绍了

Zend_Controller, Zend_View这块的 MVC 架构在 0.2.0 重新实现了
具体细节我还没有看,稍后为您介绍

另外现在 Zend Framework需要 PHP5.1.4 以上版本
建议用最新(20061106)的 PHP 5.2.0 规避一个htmlentity的缓冲区溢出漏洞

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>