SlideShare a Scribd company logo
Criandoaplicações
RESTFulcomZend
Framework2
Quem?
EltonMinetto
Graduado/pós-graduadoemCiênciadaComputação
Desenvolvedordesde1997
Professordesde2004
AutordetrêslivrossobrePHPeumsobregridcomputing
PodcasternoBizandCode
CTOdaCoderockredoCodeSquad
MembrodadiretoriadaABRAPHP
Princípios REST
Dêatodasascoisasum
identificador
http://zf2.dev/api/v1/album.album.json
http://zf2.dev/api/v1/album.album.json/1
http://example.com/customers/1234
http://www.infoq.com/br/articles/rest-introduction
Vinculeascoisas
<orderself="http://x.com/orders/1234">
<amount>23</amount>
<productref="http://x.com/products/4554"></product>
<customerref="http://x.com/customers/1234"></customer>
</order>
Utilizeosmétodospadrão
GET,PUT,POST,DELETE,HEAD,OPTIONS
Recursoscommúltiplas
representações
http://zf2.dev/api/v1/album.album.json
http://zf2.dev/api/v1/album.album.xml
ouusaroheaderAccept
Comuniquesemestado
“[...]umservidornãodeveriaguardaroestadoda
comunicaçãodequalquerumdosclientesquese
comuniquecomelealémdeumaúnicarequisição.A
razãomaisóbviaparaissoéescalabilidade-onúmerode
clientesquepodeminteragircomoservidorseria
consideravelmenteimpactadosefosseprecisomantero
estadodocliente”
ZendFramework2
DesenvolvidopelaZendjuntocoma
comunidadePHP
Maisde2anosdedesenvolvimento
Maisde200profissionaisenvolvidos
Apoio Google,Microsoft,entreoutras
Mãonamassa!
Composer
mkdir rest_zf2
cd rest_zf2
curl -sS https://getcomposer.org/installer | php
ZFTool
php composer.phar require zendframework/zftool:dev-
master
Criandooprojeto
php ./vendor/bin/zf.php create project ~/Documents/
Projects/vagrant/rest_zf2/Todo
cd Todo
php composer.phar self-update
php composer.phar install
ApacheVHost
<VirtualHost *:80>
ServerName todo.dev
DocumentRoot /vagrant/rest_zf2/Todo/public
SetEnv APPLICATION_ENV "development"
SetEnv PROJECT_ROOT "/vagrant/rest_zf2/Todo"
<Directory /vagrant/rest_zf2/Todo/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Módulos
"[]ummóduloéumacoleçãodecódigo
eoutrosarquivosqueresolveum
problemaespecíficodeumaaplicaçãoou
site."
MattewO'Phinney.ZendFrameworkprojectleader
Módulo Application
Módulo Api
Módulo Admin
CriandoomóduloApi
cd ../
php ./vendor/bin/zf.php create module Api ~/
Documents/Projects/vagrant/rest_zf2/Todo/
Bancodedados
global.php
https://gist.github.com/eminetto/5709289
sqlite3 data/todo.db
create table item (id INTEGER PRIMARY KEY
AUTOINCREMENT, description text, done int);
EntidadeseTableGateway
src/Application/Model/Item.php
https://gist.github.com/eminetto/5709294
src/Application/Model/ItemTable.php
https://gist.github.com/eminetto/5709297
Application/Module.php
https://gist.github.com/eminetto/5710850
Rota
Api/config/module.config.php
https://gist.github.com/eminetto/5709324
RestController
Módulo Application
Módulo Api
ApiControllerRestController
Api/src/Controller/RestController
https://gist.github.com/eminetto/5710862
Eventos
UmEventManageréumobjetoqueagregalistenerspara
umoumaiseventosequegera(trigger)outroseventos.
Umlisteneréumafunção/método(callback)quereagea
umevento
Módulo Application
Módulo Api
ApiControllerRestController
ApiPreProcessorPreProcessor
(segurança)
ApiPostProcessorPostProcessor
(serialização)
Criandooseventos
Alterar o api/Module.php
https://gist.github.com/eminetto/5710879
PreProcessor:
https://gist.github.com/eminetto/5710894
Application/config/entities.config.php (Segurança)
https://gist.github.com/eminetto/5710859
PostProcessor:
https://gist.github.com/eminetto/5710898
Serializando
Múltiplosformatos
php composer.phar require jms/serializer:*
src/Api/PostProcessor/AbstractPostProcessor.php
https://gist.github.com/eminetto/5710903
src/Api/PostProcessor/Json.php
https://gist.github.com/eminetto/5710908
src/Api/PostProcessor/Xml.php
https://gist.github.com/eminetto/5710915
Referências
http://www.infoq.com/br/articles/rest-introduction
http://www.slideshare.net/Alganet/rest-key
http://framework.zend.com/manual/2.2/en/user-guide/
overview.html
http://jmsyst.com/libs/serializer
https://github.com/Coderockr/ApiModule
@eminetto
http://www.eltonminetto.net
http://coderockr.com
http://code-squad.com
eminetto@coderockr.com

More Related Content

PPTX
Intro to Angular.js & Zend2 for Front-End Web Applications
TECKpert, Hubdin
 
PPTX
Building restful ap is with harvester js
Marcelo Cure
 
PDF
Apigility – Lightning Fast API Development - OSSCamp 2014
OSSCube
 
ODP
Introduction to Zend Framework
Michelangelo van Dam
 
PDF
Make your application expressive
Christian Varela
 
PDF
Build your APIs with apigility
Christian Varela
 
PPT
ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)
ZFConf Conference
 
PDF
Browser Serving Your We Application Security - ZendCon 2017
Philippe Gamache
 
Intro to Angular.js & Zend2 for Front-End Web Applications
TECKpert, Hubdin
 
Building restful ap is with harvester js
Marcelo Cure
 
Apigility – Lightning Fast API Development - OSSCamp 2014
OSSCube
 
Introduction to Zend Framework
Michelangelo van Dam
 
Make your application expressive
Christian Varela
 
Build your APIs with apigility
Christian Varela
 
ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)
ZFConf Conference
 
Browser Serving Your We Application Security - ZendCon 2017
Philippe Gamache
 

What's hot (19)

ODP
Using Zend Framework 2 Book Presentation
olegkrivtsov
 
PPTX
Lecture java basics
eleksdev
 
PDF
Breaking The Framework's Core #PHPKonf 2016
Mehmet Ince
 
PPT
Zend Framework Introduction
Rafael Monteiro
 
PDF
Deprecated: Foundations of Zend Framework 2
Adam Culp
 
PPTX
前端網頁自動測試
政億 林
 
PDF
Zend Framework 2 - presentation
yamcsha
 
PDF
Spring rest-doc-2015-11
Eric Ahn
 
PPTX
Jasmine with JS-Test-Driver
Devesh Chanchlani
 
PDF
Ane for 9ria_cn
sonicxs
 
PPTX
Get Started with Zend Framework 2
Mindfire Solutions
 
PPTX
Lecture android best practices
eleksdev
 
PDF
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Arrow Consulting & Design
 
PPTX
WordPress and Zend Framework Integration with Vulnero
Andrew Kandels
 
PPTX
Django Interview Questions and Answers
Python Devloper
 
PDF
Magento with Composer
AOE
 
PDF
Building Rich Applications with Appcelerator
Matt Raible
 
PDF
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
Using Zend Framework 2 Book Presentation
olegkrivtsov
 
Lecture java basics
eleksdev
 
Breaking The Framework's Core #PHPKonf 2016
Mehmet Ince
 
Zend Framework Introduction
Rafael Monteiro
 
Deprecated: Foundations of Zend Framework 2
Adam Culp
 
前端網頁自動測試
政億 林
 
Zend Framework 2 - presentation
yamcsha
 
Spring rest-doc-2015-11
Eric Ahn
 
Jasmine with JS-Test-Driver
Devesh Chanchlani
 
Ane for 9ria_cn
sonicxs
 
Get Started with Zend Framework 2
Mindfire Solutions
 
Lecture android best practices
eleksdev
 
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Arrow Consulting & Design
 
WordPress and Zend Framework Integration with Vulnero
Andrew Kandels
 
Django Interview Questions and Answers
Python Devloper
 
Magento with Composer
AOE
 
Building Rich Applications with Appcelerator
Matt Raible
 
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
Ad

Similar to Criando aplicações RestFul com Zend Framework 2 (20)

PDF
Doing REST Right
Kerry Buckley
 
PPTX
Building Software Backend (Web API)
Alexander Goida
 
PDF
Zend/Expressive 3 – The Next Generation
Ralf Eggert
 
PDF
Writing RESTful Web Services
Paul Boocock
 
PPT
RESTful SOA - 中科院暑期讲座
Li Yi
 
PDF
IRJET- Rest API for E-Commerce Site
IRJET Journal
 
PDF
REST API with CakePHP
Anuchit Chalothorn
 
PDF
Rest web services
Paulo Gandra de Sousa
 
ODP
RESTful Web Services with JAX-RS
Carol McDonald
 
PDF
A RESTful introduction
Daniel Toader
 
PDF
Build REST APIs like a Jedi with Symfony2
Almog Baku
 
PDF
About REST & Symfony
Maxence Poutord
 
PDF
L12: REST Service
medialeg gmbh
 
PPTX
RESTful APIs in .NET
Greg Sohl
 
PPTX
REST - You're Doing It Wrong
Sergey Shishkin
 
PDF
Restful Services
SHAKIL AKHTAR
 
PPTX
Wcf rest api introduction
Himanshu Desai
 
PPTX
Real world RESTful service development problems and solutions
Bhakti Mehta
 
PDF
Zend Expressive 3 e PSR-15
Juciellen Cabrera
 
PDF
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
IJIR JOURNALS IJIRUSA
 
Doing REST Right
Kerry Buckley
 
Building Software Backend (Web API)
Alexander Goida
 
Zend/Expressive 3 – The Next Generation
Ralf Eggert
 
Writing RESTful Web Services
Paul Boocock
 
RESTful SOA - 中科院暑期讲座
Li Yi
 
IRJET- Rest API for E-Commerce Site
IRJET Journal
 
REST API with CakePHP
Anuchit Chalothorn
 
Rest web services
Paulo Gandra de Sousa
 
RESTful Web Services with JAX-RS
Carol McDonald
 
A RESTful introduction
Daniel Toader
 
Build REST APIs like a Jedi with Symfony2
Almog Baku
 
About REST & Symfony
Maxence Poutord
 
L12: REST Service
medialeg gmbh
 
RESTful APIs in .NET
Greg Sohl
 
REST - You're Doing It Wrong
Sergey Shishkin
 
Restful Services
SHAKIL AKHTAR
 
Wcf rest api introduction
Himanshu Desai
 
Real world RESTful service development problems and solutions
Bhakti Mehta
 
Zend Expressive 3 e PSR-15
Juciellen Cabrera
 
Ijirsm ashok-kumar-ps-compulsiveness-of-res tful-web-services
IJIR JOURNALS IJIRUSA
 
Ad

More from Elton Minetto (20)

PDF
Go e Microserviços - Nascidos um para o outro
Elton Minetto
 
PDF
Object Calisthenics em Go
Elton Minetto
 
PDF
Programar != desenvolver software (v2)
Elton Minetto
 
PDF
Gerenciando uma startup no Github Projects
Elton Minetto
 
PDF
Clean Architecture
Elton Minetto
 
PDF
Serverless em Go
Elton Minetto
 
PDF
JAMstack
Elton Minetto
 
PDF
Clean architecture em Go - v2
Elton Minetto
 
PDF
Programar != desenvolver software
Elton Minetto
 
PDF
Clean Architecture em PHP
Elton Minetto
 
PDF
Clean Architecture in Golang
Elton Minetto
 
PDF
A jornada do desenvolvedor
Elton Minetto
 
PDF
Product and Technology
Elton Minetto
 
PDF
Code:Nation Tech Stack
Elton Minetto
 
PDF
Modernizando projetos legados usando APIs
Elton Minetto
 
PDF
12 factor in the PHP world
Elton Minetto
 
PDF
Building APIs using Go
Elton Minetto
 
PDF
Start you
Elton Minetto
 
PDF
O case da Compufácil e AWS
Elton Minetto
 
PDF
Introdução a Go
Elton Minetto
 
Go e Microserviços - Nascidos um para o outro
Elton Minetto
 
Object Calisthenics em Go
Elton Minetto
 
Programar != desenvolver software (v2)
Elton Minetto
 
Gerenciando uma startup no Github Projects
Elton Minetto
 
Clean Architecture
Elton Minetto
 
Serverless em Go
Elton Minetto
 
JAMstack
Elton Minetto
 
Clean architecture em Go - v2
Elton Minetto
 
Programar != desenvolver software
Elton Minetto
 
Clean Architecture em PHP
Elton Minetto
 
Clean Architecture in Golang
Elton Minetto
 
A jornada do desenvolvedor
Elton Minetto
 
Product and Technology
Elton Minetto
 
Code:Nation Tech Stack
Elton Minetto
 
Modernizando projetos legados usando APIs
Elton Minetto
 
12 factor in the PHP world
Elton Minetto
 
Building APIs using Go
Elton Minetto
 
Start you
Elton Minetto
 
O case da Compufácil e AWS
Elton Minetto
 
Introdução a Go
Elton Minetto
 

Recently uploaded (20)

PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Software Development Methodologies in 2025
KodekX
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Software Development Methodologies in 2025
KodekX
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 

Criando aplicações RestFul com Zend Framework 2