SlideShare une entreprise Scribd logo
1  sur  41
Zend Framework 陈浩 2008.10.22
[object Object],[object Object],[object Object],[object Object],About the speaker Member of Zend Framework Documentation Team (Team Lead of the Chinese Team) Translator of PHP Manual
PHP Objects, Patterns and Frameworks ,[object Object],[object Object],[object Object],[object Object],[object Object],国内的 FleaPHP, ThinkPHP 等
Contents of this presentation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
场景:川菜馆 顾客看菜谱  顾客:来一盘鱼香肉丝 服务员:好咯 服务员告诉大厨: 2 号桌要一盘鱼香肉丝 大厨辛苦劳动。。炒炒炒 搞定。告诉服务员:炒好了。 服务员把菜端给顾客 MVC 的含义 MODEL VIEW CONTROLLER
Zend Framework ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],2008 Jolt Award
 
MVC in ZF Zend_Db_Table Zend_View Zend_Controller
MVC in ZF 单一入口: index.php 项目文件目录分布
Bootstrap ( 入口文件 ) ,[object Object]
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 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Zend_Controller ,[object Object],[object Object],[object Object],http://www.phpeye.com/article/   ->  indexAction() http://www.phpeye.com/article/view/id/1   ->   viewAction()
Model  -  DB ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],数据库访问抽象的两个层次
Table Data Gateway ,[object Object]
Active Record ,[object Object]
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 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Zend_View ,[object Object],[object Object],[object Object]
PHP & Web 2.0
Zend Framework & Web 2.0 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Zend Framework & Web 2.0 Json Built-in functions of PHP 5.2 +  json_decode()  json_encode() ,[object Object],[object Object],[object Object],[object Object],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/ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Zend_Gdata
Zend Framework & Web 2.0 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
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; // "Hello Davey, Good Day" }
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 ,[object Object]
ZF & RoR ,[object Object],[object Object],[object Object],[object Object],“ I am a giant because I stand on the shoulders of others”
Drawbacks of ZF ,[object Object],[object Object],[object Object]
Too many files loaded in controllers? Generated by PECL extentsion  Inclued
Too many files loaded in controllers? Xdebug + WinCacheGrind
Opcode cache ,[object Object],[object Object],[object Object],[object Object]
Questions
Thanks MSN: [email_address]

Contenu connexe

Tendances

Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
guest5d87aa6
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
archwisp
 

Tendances (19)

Review unknown code with static analysis Zend con 2017
Review unknown code with static analysis  Zend con 2017Review unknown code with static analysis  Zend con 2017
Review unknown code with static analysis Zend con 2017
 
Php Security
Php SecurityPhp Security
Php Security
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
PHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the testsPHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the tests
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2
 
PHP MVC
PHP MVCPHP MVC
PHP MVC
 
Seam Glassfish Slidecast
Seam Glassfish SlidecastSeam Glassfish Slidecast
Seam Glassfish Slidecast
 
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QACreating "Secure" PHP Applications, Part 1, Explicit Code & QA
Creating "Secure" PHP Applications, Part 1, Explicit Code & QA
 
Introduction to PHP Lecture 1
Introduction to PHP Lecture 1Introduction to PHP Lecture 1
Introduction to PHP Lecture 1
 
Proposed PHP function: is_literal()
Proposed PHP function: is_literal()Proposed PHP function: is_literal()
Proposed PHP function: is_literal()
 
Drupal 8 entities & felds
Drupal 8 entities & feldsDrupal 8 entities & felds
Drupal 8 entities & felds
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHP
 
Concern of Web Application Security
Concern of Web Application SecurityConcern of Web Application Security
Concern of Web Application Security
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
 

En vedette (6)

S3 TKAM Chapter Two
S3 TKAM Chapter TwoS3 TKAM Chapter Two
S3 TKAM Chapter Two
 
Pecha Kucha Iris van Wijk
Pecha Kucha Iris van WijkPecha Kucha Iris van Wijk
Pecha Kucha Iris van Wijk
 
File20787
File20787File20787
File20787
 
Stuff
StuffStuff
Stuff
 
Save Bmx Track
Save Bmx TrackSave Bmx Track
Save Bmx Track
 
As 91231 resources
As 91231 resources As 91231 resources
As 91231 resources
 

Similaire à Zend Framework

Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
 
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormZend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Jeremy Kendall
 

Similaire à Zend Framework (20)

Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
 
Disregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_FormDisregard Inputs, Acquire Zend_Form
Disregard Inputs, Acquire Zend_Form
 
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
 
Framework
FrameworkFramework
Framework
 
PHPSpec BDD Framework
PHPSpec BDD FrameworkPHPSpec BDD Framework
PHPSpec BDD Framework
 
Fatc
FatcFatc
Fatc
 
Introduction to Zend Framework
Introduction to Zend FrameworkIntroduction to Zend Framework
Introduction to Zend Framework
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Zend Expressive 3 e PSR-15
Zend Expressive 3 e PSR-15Zend Expressive 3 e PSR-15
Zend Expressive 3 e PSR-15
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
 
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormZend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
 
Utilization of zend an ultimate alternate for intense data processing
Utilization of zend  an ultimate alternate for intense data processingUtilization of zend  an ultimate alternate for intense data processing
Utilization of zend an ultimate alternate for intense data processing
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Zend Framework

  • 2.
  • 3.
  • 4.
  • 5. 场景:川菜馆 顾客看菜谱 顾客:来一盘鱼香肉丝 服务员:好咯 服务员告诉大厨: 2 号桌要一盘鱼香肉丝 大厨辛苦劳动。。炒炒炒 搞定。告诉服务员:炒好了。 服务员把菜端给顾客 MVC 的含义 MODEL VIEW CONTROLLER
  • 6.
  • 7.  
  • 8. MVC in ZF Zend_Db_Table Zend_View Zend_Controller
  • 9. MVC in ZF 单一入口: index.php 项目文件目录分布
  • 10.
  • 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.
  • 14.
  • 15.
  • 16.
  • 17.
  • 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.
  • 20.
  • 21. PHP & Web 2.0
  • 22.
  • 23.
  • 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.
  • 28.
  • 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; // "Hello Davey, Good Day" }
  • 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.
  • 35.
  • 36.
  • 37. Too many files loaded in controllers? Generated by PECL extentsion Inclued
  • 38. Too many files loaded in controllers? Xdebug + WinCacheGrind
  • 39.