Northeast PHP 2013

Creando una API REST con Zend Framework 2

Michael Stowe  · 

Presentación

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

I'm gonna try the mouse again hopefully works today so i'll try the mouse again and hopefully it works by the way just a heads up this has been video recorded so during the presentation if you guys want to the wave that'd be awesome they will I

think yes let's try get the way of going to try it last year don't work I'm trying to get this here well these years we have northeast PHP wave ooh I like that happy awesome well yeah they kind of that attempt where they did though yeah balcony

yeah I like him let's delay another hour yeah nice open okay so your kitchen Rebecca started juice receiver Michael so mine is a professional software engineer 85 degrees in certified and had lower ten years of age me Hawking experience those tenure sees

have privileged ability to Versailles have agents include games with medical here law enforcement one of the audio lighting yours are too small nonprofits and numerous industrial companies it's also spoken or conferences called a noble article on phn security

is active our balls and also are nice I mean MN HP suffer in tears of an investigation of us by our sins developer advocate at constant contact we're about to help overthrow detect every day every day and this is my second year at CP oh please stop stop

yes and keep going a little bit longer so you guys to get the conference so far so good that's kind of weak come on it's last talk of the day before Terry che you know let's give it yes all right today we are we talking about building a REST API

we're gonna focus on two different parts first part why my mouse hates me first thing we're looking after lookit I know where you arrest what is the rest api why should we go with the rest versus other types ap is some good practices so i'm good

practices and then we're going to actually look at billy and rest api in Zen framework to why because it's better than symphony for those of you who maybe see in the back wearing a blue and white striped shirt that point nine by today my weight this

is Cagle this is our unofficial mascot or we can say hi Cagle it's it's just a screen guys I could talk back so it was an API I have a super awesome definition of an API but basically Web API allows the transmission day of back and forth between web

applications and preferably in a language agnostic environment so if you look at API here you have your two different servers they talk to each other the important thing here is these servers do not have access to the personal data they're not accessing

the cloud from the server they're not asking that accessing the database they're just talking each other if they're able to construct what data is being shared and how it's being interacted just like you would a normal website there are several

different types of ways we can build an API kind of three lean ideas out there first is rest which we're going to talk about the second is our PC or remote procedural calls and then there's soap which is just simple access object protocol overview

of our PC our pcs problem is very very tight couple you have to know what the procedures are you have to know what the URLs are and you have to know what parameters and what words I'll go in otherwise it's not going to work so we're not going to

spend any time talking about RPC are gonna say don't do it there's different types there's xmlrpc json-rpc we're gonna stay with rest then there's soap how many people have used soap before how many people took a shower this morning I'm

just checking here I'm a little concerned okay how many people like working with soap api's see all the hand okay we got one person's brave them say yes I half the time the wsdl doesn't work it's not sub correctly your check for go what

you're doing there's so much data being transmitted so soap used to be fairly popular it's losing in popularity other problem with soap is going to expose your methods and your operations instead of just giving data everything sent through post

calls you get this huge mountain we look at some soap calls nice emotes us hope is it can be stateless or staple and then the wsdl when done correctly so you want to send a sample soap request here you go you get this wonderful work to send a stock price and

stock name that's what you wanna do it you won't get a stock price and you get this awesome result back so now I have to press with XML you've all this data coming in is kind of a pain rest on the other hand just cuz awesome everybody got a good

night's rest right yeah I did some we fold puns today I apologize first thing it does is it returns the data we're not saying back the methods we're not saying hey this is the actual function in my code that handles this call we're just going

back data it supports XML and JSON among other types and you catch this up your rest api so you can handle multiple incoming types at the same time if they want JSON will you give them JSON if they want XML we give them XML I using explicit HTTP verbs so this

is a good bad thing rather than saying okay I make a post call and I want you to do something we're saying I want to create something let's make a post call I want to delete something I'm now going to get the week call using the delete action verb

point-to-point connections other great thing about rest is its Ajax friendly there's some security concerns you run into this but you can actually use it for Ajax and JavaScript and the other cool thing is a stateless that means you want four sessions

you have four about keeping track of what they're doing every call is unique and it's a lot simpler if we're using JSON as you see there's our call there's a result we actually have a whole much more data being sent and a hoe much more

data being received than those soap calls we have a lot more space to work with so r us versus soap this is awesome slide why because it has metals on it I don't know rest returns the data win for rest it supports XML and JSON another win where use crowd

which we'll talk about or HTTP verbs I has point-to-point connections it's Ajax friendly advantages to soap it could be stateless or staple if you're trying to do something that will be really super secure my work in that case and also the wsdl

support which is basically a or documentation of this is what does however there are things we can do with rest to kind of supplement that and offer the same solution now one thing I want to try find was the good the bad and the ugly so there's some arguments

against why you should use rest the first is rest api is are extremely difficult to build and maintain we're not going to spend five hours today to build api we're going to take about 30 minutes and build one in that time frame so they're actually

pretty quick and easy the challenge is do well follow some basic guidelines and you have to do some planning the biggest challenge will run into is they build this api just like build a website and they don't think long term and so next month we have to

change it and the problems we have a hundred clients using that API they're not gonna be very happy I also a documentation and these slides we posted online later you can check out the bitly link there's a great article and using JSON to actually keep

your documentation up to date as well so you know what calls are being used rest is not secure absolutely false with rest and you can use OAuth tokens you can use API keys and you're able to really determine what people have information or what access

they have based on those just like you would with any web service the time it becomes really unsecured and secure is when you're using Ajax or JavaScript why because it's front-end code its client side code anybody can see what that is so if you're

saying API key that supposed to be top secret and your secret token through JavaScript not really that good of idea and lastly there are no strict standards for rest there are not if you go out on the web you hook at different rest api's there's 10,000

[ ... ]

Nota: se han omitido las otras 4.066 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.