SlideShare a Scribd company logo
Zend Framework 陈浩 2008.10.22
陈浩  haohappy Chinese Translator of: Programming PHP  2 nd  edition  《 PHP 程序设计》第二版 PHP Objects, Pattens, and Practice  2 nd  edition  《 PHP 对象、模式与实践》第二版 About the speaker Member of Zend Framework Documentation Team (Team Lead of the Chinese Team) Translator of PHP Manual
PHP Objects, Patterns and Frameworks PHP4 退出历史舞台, PHP5 成为主流 PHP5 对于面向对象的支持大大加强 反射( reflection )、异常( exception )、私有和保护( private 和 protected )的方法和属性、 __toString() 方法、 static 修饰符、抽象类和抽象方法、 final 方法和属性、接口、迭代器( iterator )、拦截器( interceptor )方法、类型检查、 const 关键字、引用传递、 __clone() 方法和 __construct() 构造方法等等。  面向对象的 PHP 开发  设计模式的应用 面向对象的 PHP 开发框架 国内的 FleaPHP, ThinkPHP 等
Contents of this presentation Brief Introduction of ZF MVC  Database Useful libs  48 in total Web2.0   Dojo, Json, Soap, Rest, XmlRpc, Amf new , Services_*, Gdata Generic  Auth, Acl, Form, Layout, Cache, Config, Paginator, Mail, Validate, Http
场景:川菜馆 顾客看菜谱  顾客:来一盘鱼香肉丝 服务员:好咯 服务员告诉大厨: 2 号桌要一盘鱼香肉丝 大厨辛苦劳动。。炒炒炒 搞定。告诉服务员:炒好了。 服务员把菜端给顾客 MVC 的含义 MODEL VIEW CONTROLLER
Zend Framework 开放源代码的 PHP5 开发框架  易于学习和使用 功能强大,促进快速开发 有活跃的开发者社区和完善的支持平台 BSD 许可 适合商业应用 由 Zend 公司主导开发 合作: 2008 Jolt Award
 
MVC in ZF Zend_Db_Table Zend_View Zend_Controller
MVC in ZF 单一入口: index.php 项目文件目录分布
Bootstrap ( 入口文件 ) <?php  //  控制器实例化  $controller =  Zend_Controller_Front :: getInstance ();  $controller -> setControllerDirectory ( $controllerDir );  //  设置路由  $router  = new  Zend_Controller_Router_Route_Rewrite ();  $controller -> setRouter ( $router );  //  设置请求对象  $request  = new  Zend_Controller_Request_Http ();  $controller -> setRequest ( $request );  $controller -> throwExceptions ( true );  $controller -> returnResponse ( true );  //  得到响应对象  $response  =  $controller -> dispatch ();  //  输出  echo  $response ;  ?>
Zend_Controller
Zend_Controller 用户访问: http://www.phpeye.com/article/view/id/1 Apache Server:  url_rewrite 转向所有请求到入口文件  index.php  index.php  初始化控制器 Router 对 URL 进行分解  根据路由规则,决定调用哪个 controller 中的哪个 action Dispatcher  调用 controller 中的 action
Zend_Controller Zend_Controller_Front  设置 controller 目录,生成 request 对象,并 dispatch() Zend_Controller_Request_Abstract  默认使用 Zend_Controller_Request_Http Zend_Controller_Router_Interface 决定调用哪个 Controller 中的哪个 Action  Zend_Controller_Dispatcher_Interface 调用 controller 中的 Action
Zend_Controller class  ArticleController  extends  Zend_Controller_Action  {      public function  indexAction ()      {      }    public function  viewAction () {   $articleId = $this->request-> getParam(‘id’);   $article = $this->article->find($articleId);   $this->view->article = $article;   $this->view->render();// 不需要指定模板   } } http://www.phpeye.com/article/   ->  indexAction() http://www.phpeye.com/article/view/id/1   ->   viewAction()
Model  -  DB 1.  数据库软件的抽象  基于 PDO (PHP Data Objects) MySQL, OCI, PostgreSQL, ODBC, DB2, SQLite, Sybase/FreeTDS/MSSQL 2. SQL 抽象 多个层次 Zend_Db  手写 Sql  $this->db->query($sql); Zend_Db_Select  部分手写 Zend_Db_Table  基本不用写 Sql Zend_Db_Table_Row Row Data Gateway   Zend_Db_Table_Rowset 数据库访问抽象的两个层次
Table Data Gateway An object that acts as a Gateway to a database table. One instance handles all the rows in the table.
Active Record An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
CRUD Zend_Db_Table $rows_affected = $this->insert($data); $rows_affected = $this->update($data, $where); $rows_affected = $this->delete($where); $rowset = $this->find($id); Zend_Db $this->db->query($sql);
Zend_View <html> <head> <title ><?php echo $title ?></title> </head> <body> <?php echo $body ?> </body> </html>
Zend_View PHP is template language itself. You don’t need another one. Just separate your logic from your presentation.  View Renderer  Compatible with other template systems, such as Smarty, HTML_Template_PHPLIB, etc.
PHP & Web 2.0
Zend Framework & Web 2.0 Json, Soap, Rest, XmlRpc, Amf new , Dojo,   Gdata Zend_Services_*  针对某个特定网站的 API 访问客户端 Zend_Service_Akismet  Zend_Service_Amazon  Zend_Service_Audioscrobbler  Zend_Service_Delicious  Zend_Service_Flickr  Zend_Service_Nirvanix  Zend_Service_ReCaptcha  Zend_Service_Simpy  Zend_Service_SlideShare  Zend_Service_StrikeIron  Zend_Service_Technorati  Zend_Service_Yahoo
Zend Framework & Web 2.0 Json Built-in functions of PHP 5.2 +  json_decode()  json_encode() Zend_Json Json/PHP 数据互相转换 服务器端 XML  ->  Json  ->   输出到浏览器 JSON-RPC Server   同时支持 Json-rpc v1, v2 规范 Next
Zend Framework & Web 2.0 Json Back
Zend Framework & Web 2.0 Json // fromXml function simply takes a String containing XML contents as input. $jsonContents = Zend_Json::fromXml($xmlStringContents, true);  Back
Zend Framework & Web 2.0 Json Back
Zend Framework & Web 2.0 Gdata http://code.google.com/apis/gdata/ Google Calendar   Google Spreadsheets   Google Documents List   Google Provisioning Google Base   YouTube Picasa Web Albums   Google Blogger   Google CodeSearch Google Notebook Zend_Gdata
Zend Framework & Web 2.0 Zend_Services_*  针对某个特定网站的 API 访问客户端 Zend_Service_Akismet  Zend_Service_Amazon  Zend_Service_Audioscrobbler  Zend_Service_Delicious  Zend_Service_Flickr  Zend_Service_Nirvanix  Zend_Service_ReCaptcha  Zend_Service_Simpy  Zend_Service_SlideShare  Zend_Service_StrikeIron  Zend_Service_Technorati  Zend_Service_Yahoo
Zend Framework & Web 2.0 REST Zend_Rest_Client Zend_Rest_Server
Zend Framework & Web 2.0 REST Zend_Rest_Client $serverUrl =  'http://framework.zend.com/rest'; $client = new Zend_Rest_Client($serverUrl); $result = $client->sayHello('Davey', 'Day') ->get(); if ($result->isSuccess()) {     echo $result; // &quot;Hello Davey, Good Day&quot; }
Zend Framework & Web 2.0 REST Zend_Rest_Client /** *  在 Technorati 上查找某个博客的作者 */ $technoratiUrl =  'http://api.technorati.com/bloginfo'; $technorati = new Zend_Rest_Client( $technoratiUrl); $technorati->key($key); $technorati->url('http://pixelated-dreams.com'); $result = $technorati->get(); echo $result->firstname() .' '. $result->lastname();
Zend Framework & Web 2.0 REST Zend_Rest_Server $server = new Zend_Rest_Server(); $server->setClass('My_Service_Class'); $server->handle();  Class My_Service_Class(){ public function sayHello(){ //return XML here } }
Zend_Amf 支持  Adobe 的  Action Message Format  (AMF) 允许浏览器端的 Flash Player   与 PHP 进行通信 .  另外,可以将 Actions Script 中的数据(如对象)方便地转换成 PHP 中的数据。 PHP Flash Server Client
Useful libs Auth, Acl, Form, Layout, Cache, Config, Paginator, Mail, Validate, Http
ZF & RoR Convention Over Configuration 约定高于配置  Zend_View  view renderer flexibility has a cost Dynamic Helpers For Views 动态的 View Helper Generate Components For Application 自动生成系统部件  Zend_Tool “ I am a giant because I stand on the shoulders of others”
Drawbacks of ZF Performance ?  Coupling ? Complexity?
Too many files loaded in controllers? Generated by PECL extentsion  Inclued
Too many files loaded in controllers? Xdebug + WinCacheGrind
Opcode cache APC  will be support in PHP6 eAccelerator Xcache Zend Optimizer
Questions
Thanks MSN: [email_address]

More Related Content

What's hot (18)

PDF
Review unknown code with static analysis Zend con 2017
Damien Seguy
 
PDF
Php Security
guest7cf35c
 
PPS
PHP Security
manugoel2003
 
PDF
PHPUnit Episode iv.iii: Return of the tests
Michelangelo van Dam
 
PPT
PHP Security
Mindfire Solutions
 
PPT
Jquery presentation
guest5d87aa6
 
PPT
Php Security By Mugdha And Anish
OSSCube
 
PDF
November Camp - Spec BDD with PHPSpec 2
Kacper Gunia
 
PDF
Seam Glassfish Slidecast
Eduardo Pelegri-Llopart
 
PPTX
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
archwisp
 
PPTX
Introduction to PHP Lecture 1
Ajay Khatri
 
PDF
Proposed PHP function: is_literal()
Craig Francis
 
ODP
Drupal 8 entities & felds
Andy Postnikov
 
PPTX
Basics of Java Script (JS)
Ajay Khatri
 
PDF
Functional Structures in PHP
Marcello Duarte
 
ODP
Concern of Web Application Security
Mahmud Ahsan
 
PDF
Your code sucks, let's fix it
Rafael Dohms
 
Review unknown code with static analysis Zend con 2017
Damien Seguy
 
Php Security
guest7cf35c
 
PHP Security
manugoel2003
 
PHPUnit Episode iv.iii: Return of the tests
Michelangelo van Dam
 
PHP Security
Mindfire Solutions
 
Jquery presentation
guest5d87aa6
 
Php Security By Mugdha And Anish
OSSCube
 
November Camp - Spec BDD with PHPSpec 2
Kacper Gunia
 
Seam Glassfish Slidecast
Eduardo Pelegri-Llopart
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
archwisp
 
Introduction to PHP Lecture 1
Ajay Khatri
 
Proposed PHP function: is_literal()
Craig Francis
 
Drupal 8 entities & felds
Andy Postnikov
 
Basics of Java Script (JS)
Ajay Khatri
 
Functional Structures in PHP
Marcello Duarte
 
Concern of Web Application Security
Mahmud Ahsan
 
Your code sucks, let's fix it
Rafael Dohms
 

Viewers also liked (6)

PPT
S3 TKAM Chapter Two
Nurhayati Dehandschutter
 
PPT
Pecha Kucha Iris van Wijk
IrisIris
 
PDF
File20787
Deepak Deshmukh
 
PPT
Stuff
lpscott
 
PPT
Save Bmx Track
lpscott
 
PPT
As 91231 resources
Henry Hollis
 
S3 TKAM Chapter Two
Nurhayati Dehandschutter
 
Pecha Kucha Iris van Wijk
IrisIris
 
File20787
Deepak Deshmukh
 
Stuff
lpscott
 
Save Bmx Track
lpscott
 
As 91231 resources
Henry Hollis
 
Ad

Similar to Zend Framework (20)

ODP
Zend Framework 1.9 Setup & Using Zend_Tool
Gordon Forsythe
 
ODP
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
PDF
Disregard Inputs, Acquire Zend_Form
Daniel Cousineau
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
James Titcumb
 
KEY
Zend Framework Study@Tokyo #2
Shinya Ohyanagi
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
James Titcumb
 
PPT
Framework
Nguyen Linh
 
PDF
PHPSpec BDD Framework
Marcello Duarte
 
KEY
Fatc
Wade Arnold
 
ODP
Introduction to Zend Framework
Michelangelo van Dam
 
PDF
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
PDF
Intro To Mvc Development In Php
funkatron
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
James Titcumb
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
James Titcumb
 
PDF
Building Testable PHP Applications
chartjes
 
PDF
Zend Expressive 3 e PSR-15
Juciellen Cabrera
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
James Titcumb
 
ODP
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Jeremy Kendall
 
PDF
Utilization of zend an ultimate alternate for intense data processing
Career at Elsner
 
PPT
PHPBootcamp - Zend Framework
thomasw
 
Zend Framework 1.9 Setup & Using Zend_Tool
Gordon Forsythe
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
Disregard Inputs, Acquire Zend_Form
Daniel Cousineau
 
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
James Titcumb
 
Zend Framework Study@Tokyo #2
Shinya Ohyanagi
 
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
James Titcumb
 
Framework
Nguyen Linh
 
PHPSpec BDD Framework
Marcello Duarte
 
Introduction to Zend Framework
Michelangelo van Dam
 
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
Intro To Mvc Development In Php
funkatron
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
James Titcumb
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
James Titcumb
 
Building Testable PHP Applications
chartjes
 
Zend Expressive 3 e PSR-15
Juciellen Cabrera
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
James Titcumb
 
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Jeremy Kendall
 
Utilization of zend an ultimate alternate for intense data processing
Career at Elsner
 
PHPBootcamp - Zend Framework
thomasw
 
Ad

Recently uploaded (20)

PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
July Patch Tuesday
Ivanti
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 

Zend Framework

  • 2. 陈浩 haohappy Chinese Translator of: Programming PHP 2 nd edition 《 PHP 程序设计》第二版 PHP Objects, Pattens, and Practice 2 nd edition 《 PHP 对象、模式与实践》第二版 About the speaker Member of Zend Framework Documentation Team (Team Lead of the Chinese Team) Translator of PHP Manual
  • 3. PHP Objects, Patterns and Frameworks PHP4 退出历史舞台, PHP5 成为主流 PHP5 对于面向对象的支持大大加强 反射( reflection )、异常( exception )、私有和保护( private 和 protected )的方法和属性、 __toString() 方法、 static 修饰符、抽象类和抽象方法、 final 方法和属性、接口、迭代器( iterator )、拦截器( interceptor )方法、类型检查、 const 关键字、引用传递、 __clone() 方法和 __construct() 构造方法等等。 面向对象的 PHP 开发 设计模式的应用 面向对象的 PHP 开发框架 国内的 FleaPHP, ThinkPHP 等
  • 4. Contents of this presentation Brief Introduction of ZF MVC Database Useful libs 48 in total Web2.0 Dojo, Json, Soap, Rest, XmlRpc, Amf new , Services_*, Gdata Generic Auth, Acl, Form, Layout, Cache, Config, Paginator, Mail, Validate, Http
  • 5. 场景:川菜馆 顾客看菜谱 顾客:来一盘鱼香肉丝 服务员:好咯 服务员告诉大厨: 2 号桌要一盘鱼香肉丝 大厨辛苦劳动。。炒炒炒 搞定。告诉服务员:炒好了。 服务员把菜端给顾客 MVC 的含义 MODEL VIEW CONTROLLER
  • 6. Zend Framework 开放源代码的 PHP5 开发框架 易于学习和使用 功能强大,促进快速开发 有活跃的开发者社区和完善的支持平台 BSD 许可 适合商业应用 由 Zend 公司主导开发 合作: 2008 Jolt Award
  • 7.  
  • 8. MVC in ZF Zend_Db_Table Zend_View Zend_Controller
  • 9. MVC in ZF 单一入口: index.php 项目文件目录分布
  • 10. Bootstrap ( 入口文件 ) <?php //  控制器实例化 $controller =  Zend_Controller_Front :: getInstance (); $controller -> setControllerDirectory ( $controllerDir ); //  设置路由 $router  = new  Zend_Controller_Router_Route_Rewrite (); $controller -> setRouter ( $router ); //  设置请求对象 $request  = new  Zend_Controller_Request_Http (); $controller -> setRequest ( $request ); $controller -> throwExceptions ( true ); $controller -> returnResponse ( true ); //  得到响应对象 $response  =  $controller -> dispatch (); //  输出 echo  $response ; ?>
  • 12. Zend_Controller 用户访问: http://www.phpeye.com/article/view/id/1 Apache Server: url_rewrite 转向所有请求到入口文件 index.php index.php 初始化控制器 Router 对 URL 进行分解 根据路由规则,决定调用哪个 controller 中的哪个 action Dispatcher 调用 controller 中的 action
  • 13. Zend_Controller Zend_Controller_Front 设置 controller 目录,生成 request 对象,并 dispatch() Zend_Controller_Request_Abstract 默认使用 Zend_Controller_Request_Http Zend_Controller_Router_Interface 决定调用哪个 Controller 中的哪个 Action Zend_Controller_Dispatcher_Interface 调用 controller 中的 Action
  • 14. Zend_Controller class  ArticleController  extends  Zend_Controller_Action {     public function  indexAction ()     {     } public function viewAction () { $articleId = $this->request-> getParam(‘id’); $article = $this->article->find($articleId); $this->view->article = $article; $this->view->render();// 不需要指定模板 } } http://www.phpeye.com/article/ -> indexAction() http://www.phpeye.com/article/view/id/1 -> viewAction()
  • 15. Model - DB 1. 数据库软件的抽象 基于 PDO (PHP Data Objects) MySQL, OCI, PostgreSQL, ODBC, DB2, SQLite, Sybase/FreeTDS/MSSQL 2. SQL 抽象 多个层次 Zend_Db 手写 Sql $this->db->query($sql); Zend_Db_Select 部分手写 Zend_Db_Table 基本不用写 Sql Zend_Db_Table_Row Row Data Gateway Zend_Db_Table_Rowset 数据库访问抽象的两个层次
  • 16. Table Data Gateway An object that acts as a Gateway to a database table. One instance handles all the rows in the table.
  • 17. Active Record An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
  • 18. CRUD Zend_Db_Table $rows_affected = $this->insert($data); $rows_affected = $this->update($data, $where); $rows_affected = $this->delete($where); $rowset = $this->find($id); Zend_Db $this->db->query($sql);
  • 19. Zend_View <html> <head> <title ><?php echo $title ?></title> </head> <body> <?php echo $body ?> </body> </html>
  • 20. Zend_View PHP is template language itself. You don’t need another one. Just separate your logic from your presentation. View Renderer Compatible with other template systems, such as Smarty, HTML_Template_PHPLIB, etc.
  • 21. PHP & Web 2.0
  • 22. Zend Framework & Web 2.0 Json, Soap, Rest, XmlRpc, Amf new , Dojo, Gdata Zend_Services_* 针对某个特定网站的 API 访问客户端 Zend_Service_Akismet Zend_Service_Amazon Zend_Service_Audioscrobbler Zend_Service_Delicious Zend_Service_Flickr Zend_Service_Nirvanix Zend_Service_ReCaptcha Zend_Service_Simpy Zend_Service_SlideShare Zend_Service_StrikeIron Zend_Service_Technorati Zend_Service_Yahoo
  • 23. Zend Framework & Web 2.0 Json Built-in functions of PHP 5.2 + json_decode() json_encode() Zend_Json Json/PHP 数据互相转换 服务器端 XML -> Json -> 输出到浏览器 JSON-RPC Server 同时支持 Json-rpc v1, v2 规范 Next
  • 24. Zend Framework & Web 2.0 Json Back
  • 25. Zend Framework & Web 2.0 Json // fromXml function simply takes a String containing XML contents as input. $jsonContents = Zend_Json::fromXml($xmlStringContents, true); Back
  • 26. Zend Framework & Web 2.0 Json Back
  • 27. Zend Framework & Web 2.0 Gdata http://code.google.com/apis/gdata/ Google Calendar Google Spreadsheets Google Documents List Google Provisioning Google Base YouTube Picasa Web Albums Google Blogger Google CodeSearch Google Notebook Zend_Gdata
  • 28. Zend Framework & Web 2.0 Zend_Services_* 针对某个特定网站的 API 访问客户端 Zend_Service_Akismet Zend_Service_Amazon Zend_Service_Audioscrobbler Zend_Service_Delicious Zend_Service_Flickr Zend_Service_Nirvanix Zend_Service_ReCaptcha Zend_Service_Simpy Zend_Service_SlideShare Zend_Service_StrikeIron Zend_Service_Technorati Zend_Service_Yahoo
  • 29. Zend Framework & Web 2.0 REST Zend_Rest_Client Zend_Rest_Server
  • 30. Zend Framework & Web 2.0 REST Zend_Rest_Client $serverUrl = 'http://framework.zend.com/rest'; $client = new Zend_Rest_Client($serverUrl); $result = $client->sayHello('Davey', 'Day') ->get(); if ($result->isSuccess()) {     echo $result; // &quot;Hello Davey, Good Day&quot; }
  • 31. Zend Framework & Web 2.0 REST Zend_Rest_Client /** * 在 Technorati 上查找某个博客的作者 */ $technoratiUrl = 'http://api.technorati.com/bloginfo'; $technorati = new Zend_Rest_Client( $technoratiUrl); $technorati->key($key); $technorati->url('http://pixelated-dreams.com'); $result = $technorati->get(); echo $result->firstname() .' '. $result->lastname();
  • 32. Zend Framework & Web 2.0 REST Zend_Rest_Server $server = new Zend_Rest_Server(); $server->setClass('My_Service_Class'); $server->handle(); Class My_Service_Class(){ public function sayHello(){ //return XML here } }
  • 33. Zend_Amf 支持 Adobe 的 Action Message Format (AMF) 允许浏览器端的 Flash Player 与 PHP 进行通信 . 另外,可以将 Actions Script 中的数据(如对象)方便地转换成 PHP 中的数据。 PHP Flash Server Client
  • 34. Useful libs Auth, Acl, Form, Layout, Cache, Config, Paginator, Mail, Validate, Http
  • 35. ZF & RoR Convention Over Configuration 约定高于配置 Zend_View view renderer flexibility has a cost Dynamic Helpers For Views 动态的 View Helper Generate Components For Application 自动生成系统部件 Zend_Tool “ I am a giant because I stand on the shoulders of others”
  • 36. Drawbacks of ZF Performance ? Coupling ? Complexity?
  • 37. Too many files loaded in controllers? Generated by PECL extentsion Inclued
  • 38. Too many files loaded in controllers? Xdebug + WinCacheGrind
  • 39. Opcode cache APC will be support in PHP6 eAccelerator Xcache Zend Optimizer