Ole marius smestad - REST & PHP API : how to turn eZ Publish into a multi-channel machine
Upcoming SlideShare
Loading in...5
×
 

Ole marius smestad - REST & PHP API : how to turn eZ Publish into a multi-channel machine

on

  • 82,545 views

 

Statistics

Views

Total Views
82,545
Views on SlideShare
82,454
Embed Views
91

Actions

Likes
1
Downloads
28
Comments
0

5 Embeds 91

http://share.ez.no 78
http://one.community.ec2.ez.no 9
http://paper.li 2
http://twitter.com 1
http://ez46 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Ole marius smestad - REST & PHP API : how to turn eZ Publish into a multi-channel machine Ole marius smestad - REST & PHP API : how to turn eZ Publish into a multi-channel machine Presentation Transcript

  • REST & PHP API eZ Winter Conference 2011, Nicemandag 31. januar 2011 1
  • Introduction 2mandag 31. januar 2011 2
  • About me Ole Marius Smestad Lead engineer for eZ Publish oms@ez.no @dotten Presenter: Ole Marius Smestad 27.01.2011 3mandag 31. januar 2011 3 View slide
  • Agenda Presenter: Ole Marius Smestad 27.01.2011 4mandag 31. januar 2011 4 View slide
  • Agenda News and conceptual feature discussion Presenter: Ole Marius Smestad 27.01.2011 4mandag 31. januar 2011 4
  • Agenda News and conceptual feature discussion What has been done Presenter: Ole Marius Smestad 27.01.2011 4mandag 31. januar 2011 4
  • Agenda News and conceptual feature discussion What has been done What is being delivered Presenter: Ole Marius Smestad 27.01.2011 4mandag 31. januar 2011 4
  • Agenda News and conceptual feature discussion What has been done What is being delivered How to put this work to use Presenter: Ole Marius Smestad 27.01.2011 4mandag 31. januar 2011 4
  • Agenda News and conceptual feature discussion What has been done What is being delivered How to put this work to use A bit of code Presenter: Ole Marius Smestad 27.01.2011 4mandag 31. januar 2011 4
  • A retrospective 5mandag 31. januar 2011 5
  • A retrospective APIs Presenter: Ole Marius Smestad 27.01.2011 6mandag 31. januar 2011 6
  • A retrospective PHP eZ Publish API REST Presenter: Ole Marius Smestad 27.01.2011 7mandag 31. januar 2011 7
  • PHP APIs should be Simple Presenter: Ole Marius Smestad 27.01.2011 8mandag 31. januar 2011 8
  • PHP APIs should be Simple Consistent Presenter: Ole Marius Smestad 27.01.2011 8mandag 31. januar 2011 8
  • PHP APIs should be Simple Consistent Predictable Presenter: Ole Marius Smestad 27.01.2011 8mandag 31. januar 2011 8
  • PHP APIs should be A clear relationship Presenter: Ole Marius Smestad 27.01.2011 9mandag 31. januar 2011 9
  • PHP APIs should be A clear relationship Concepts Objects Tasks Presenter: Ole Marius Smestad 27.01.2011 9mandag 31. januar 2011 9
  • PHP APIs should be Simple Consistent Predictable Presenter: Ole Marius Smestad 27.01.2011 10mandag 31. januar 2011 10
  • PHP APIs should be Simple Consistent Predictable A stable point of reference Presenter: Ole Marius Smestad 27.01.2011 10mandag 31. januar 2011 10
  • A retrospective PHP eZ Publish API REST Presenter: Ole Marius Smestad 27.01.2011 11mandag 31. januar 2011 11
  • A retrospective REST Presenter: Ole Marius Smestad 27.01.2011 12mandag 31. januar 2011 12
  • A retrospective REST REST Presenter: Ole Marius Smestad 27.01.2011 12mandag 31. januar 2011 12
  • ( ) Presenter: Ole Marius Smestad 27.01.2011 13mandag 31. januar 2011 13
  • REST REST as a core feature Presenter: Ole Marius Smestad 27.01.2011 14mandag 31. januar 2011 14
  • REST HTTP is the carrier Presenter: Ole Marius Smestad 27.01.2011 15mandag 31. januar 2011 15
  • REST dedicated front-controller Presenter: Ole Marius Smestad 27.01.2011 16mandag 31. januar 2011 16
  • REST back to the mothership Presenter: Ole Marius Smestad 27.01.2011 17mandag 31. januar 2011 17
  • REST REST setup REST eZP REST  reqest FC eZ  Publish web-­‐request Presenter: Ole Marius Smestad 27.01.2011 18mandag 31. januar 2011 18
  • REST REST setup REST eZP FC Presenter: Ole Marius Smestad 27.01.2011 19mandag 31. januar 2011 19
  • REST mapping content into resources Presenter: Ole Marius Smestad 27.01.2011 20mandag 31. januar 2011 20
  • REST Makes data available Presenter: Ole Marius Smestad 27.01.2011 21mandag 31. januar 2011 21
  • REST Makes data reusable Presenter: Ole Marius Smestad 27.01.2011 21mandag 31. januar 2011 21
  • REST content is liberated Presenter: Ole Marius Smestad 27.01.2011 22mandag 31. januar 2011 22
  • One point oh 23mandag 31. januar 2011 23
  • One point oh Presenter: Ole Marius Smestad 27.01.2011 24mandag 31. januar 2011 24
  • One point oh Being released as a part of Matterhorn Presenter: Ole Marius Smestad 27.01.2011 24mandag 31. januar 2011 24
  • One point oh Being released as a part of Matterhorn Focus on infrastructure and basics Presenter: Ole Marius Smestad 27.01.2011 24mandag 31. januar 2011 24
  • One point oh Being released as a part of Matterhorn Focus on infrastructure and basics Making content accessible (in useful ways) Presenter: Ole Marius Smestad 27.01.2011 24mandag 31. januar 2011 24
  • One point oh Being released as a part of Matterhorn Focus on infrastructure and basics Making content accessible (in useful ways) Always adaptable Presenter: Ole Marius Smestad 27.01.2011 24mandag 31. januar 2011 24
  • One point oh Github repositories available today Presenter: Ole Marius Smestad 27.01.2011 25mandag 31. januar 2011 25
  • One point oh – the fineprint Presenter: Ole Marius Smestad 27.01.2011 26mandag 31. januar 2011 26
  • One point oh – the fineprint Wonʼt support full CRUD in 1.0 Presenter: Ole Marius Smestad 27.01.2011 26mandag 31. januar 2011 26
  • One point oh – the fineprint Wonʼt support full CRUD in 1.0 Waiting for additions to our PHP API to fully support this Presenter: Ole Marius Smestad 27.01.2011 26mandag 31. januar 2011 26
  • One point oh – the fineprint Wonʼt support full CRUD in 1.0 Waiting for additions to our PHP API to fully support this Applies to built-in content resources Presenter: Ole Marius Smestad 27.01.2011 26mandag 31. januar 2011 26
  • One point oh – the fineprint Wonʼt support full CRUD in 1.0 Waiting for additions to our PHP API to fully support this Applies to built-in content resources REST extensions will be able to provide all operations from day one Presenter: Ole Marius Smestad 27.01.2011 26mandag 31. januar 2011 26
  • One point oh – the fineprint Wonʼt support full CRUD in 1.0 Waiting for additions to our PHP API to fully support this Applies to built-in content resources REST extensions will be able to provide all operations from day one Presenter: Ole Marius Smestad 27.01.2011 26mandag 31. januar 2011 26
  • Key features 27mandag 31. januar 2011 27
  • Key features content resources Presenter: Ole Marius Smestad 27.01.2011 28mandag 31. januar 2011 28
  • Getting node data GET /[api]/ezp/v1/content/⤦ node/<ID> HTTP/1.1 Presenter: Ole Marius Smestad 27.01.2011 29mandag 31. januar 2011 29
  • Getting node data Presenter: Ole Marius Smestad 27.01.2011 30mandag 31. januar 2011 30
  • Getting node data classIdentifier objectName datePublished dateModified remoteID objectRemoteID nodeID objectID Full URL, etc. Presenter: Ole Marius Smestad 27.01.2011 30mandag 31. januar 2011 30
  • Getting fields GET /[api]/ezp/v1/content/⤦ object/<objectId>/fields⤦ HTTP/1.1 Presenter: Ole Marius Smestad 27.01.2011 31mandag 31. januar 2011 31
  • Getting fields fields/<fieldname> type (datatype string) identifier (attribute identifier) value (string representation of data) id (object attribute numerical ID) classattribute_id (class attribute numerical ID) Presenter: Ole Marius Smestad 27.01.2011 32mandag 31. januar 2011 32
  • Getting a specific field GET /[api]/ezp/v1/content/⤦ object/<objectId>/field/⤦ <FieldIdentifier> HTTP/1.1 Presenter: Ole Marius Smestad 27.01.2011 33mandag 31. januar 2011 33
  • Key features Rendered view Presenter: Ole Marius Smestad 27.01.2011 34mandag 31. januar 2011 34
  • Key features Systematic URLs Response groups Other resources available child lists sorting Presenter: Ole Marius Smestad 27.01.2011 35mandag 31. januar 2011 35
  • Extending the REST API 36mandag 31. januar 2011 36
  • Extending REST URI pattern Presenter: Ole Marius Smestad 27.01.2011 37mandag 31. januar 2011 37
  • URI pattern Just a token to trigger your rewrite rule Call + GET Host / Prefix / Provider / Version / params ezpRestPrefixFilterInterface Presenter: Ole Marius Smestad 27.01.2011 38mandag 31. januar 2011 38
  • URI pattern Just a token to trigger your rewrite rule Prefix Provider Version ezpRestPrefixFilterInterface Presenter: Ole Marius Smestad 27.01.2011 38mandag 31. januar 2011 38
  • URI pattern Prefix Just a token to trigger your rewrite rule Provider Version ezpRestPrefixFilterInterface Presenter: Ole Marius Smestad 27.01.2011 38mandag 31. januar 2011 38
  • URI pattern Prefix Just a token to trigger your rewrite rule Provider Version ezpRestPrefixFilterInterface Presenter: Ole Marius Smestad 27.01.2011 38mandag 31. januar 2011 38
  • URI pattern Prefix Just a token to trigger your rewrite rule Provider ezpRestPrefixFilterInterface Version Presenter: Ole Marius Smestad 27.01.2011 38mandag 31. januar 2011 38
  • URI pattern Prefix Just a token to trigger your rewrite rule Provider ezpRestPrefixFilterInterface Version Presenter: Ole Marius Smestad 27.01.2011 38mandag 31. januar 2011 38
  • URI pattern Prefix Just a token to trigger your rewrite rule Provider ezpRestPrefixFilterInterface Version Presenter: Ole Marius Smestad 27.01.2011 38mandag 31. januar 2011 38
  • Remember, rememberezpRestPrefixFilterInterface Presenter: Ole Marius Smestad 27.01.2011 39mandag 31. januar 2011 39
  • Prefix filter Always knows Current provider Current parsed version value Presenter: Ole Marius Smestad 27.01.2011 40mandag 31. januar 2011 40
  • Versioned API class ezpRestRouter extends ezcMvcRouter { public function createRoutes() { // ezpRestApiProvider $routes = array( new ezcMvcRailsRoute( /content/node/:nodeId/listAtom, ezpRestAtomController, collection ), new ezcMvcRailsRoute( /content/node/:nodeId/list, ezpRestContentController, list ), new ezcMvcRailsRoute( /content/node/:nodeId, ezpRestContentController, viewContent ), new ezcMvcRailsRoute( /content/node/:nodeId/fields, ezpRestContentController, viewFields ), new ezcMvcRailsRoute( /content/node/:nodeId/field/:fieldIdentifier, ezpRestContentController, viewFie new ezcMvcRailsRoute( /content/object/:objectId, ezpRestContentController, viewContent ), new ezcMvcRailsRoute( /content/object/:objectId/fields, ezpRestContentController, viewFields ), new ezcMvcRailsRoute( /content/object/:objectId/field/:fieldIdentifier, ezpRestContentController, vie new ezpRestVersionedRoute( new ezcMvcRailsRoute( /foo, myController, myActionOne ), 1 ), new ezpRestVersionedRoute( new ezcMvcRailsRoute( e/foo, myController2 or myControlerWhichExtendsmyContr myBetterAndScalingAction ), 2 ), ); return ezcMvcRouter::prefix( /api, $routes ); } } Presenter: Ole Marius Smestad 27.01.2011 41mandag 31. januar 2011 41
  • Versioned API ezpRestVersionedRoute Presenter: Ole Marius Smestad 27.01.2011 42mandag 31. januar 2011 42
  • Versioned API Version makes the notion version a part of the routing decision Presenter: Ole Marius Smestad 27.01.2011 43mandag 31. januar 2011 43
  • Extending the interface REST providers Presenter: Ole Marius Smestad 27.01.2011 44mandag 31. januar 2011 44
  • Extending the interface ezpRestProviderInterface Presenter: Ole Marius Smestad 27.01.2011 45mandag 31. januar 2011 45
  • Extending the REST interface Overview of hooks Presenter: Ole Marius Smestad 27.01.2011 46mandag 31. januar 2011 46
  • Presenter: Ole Marius Smestad 27.01.2011 47mandag 31. januar 2011 47
  • Route setup 1 class ezpRestRouter extends ezcMvcRouter { public function createRoutes() { // ezpRestApiProvider $routes = array( new ezcMvcRailsRoute( /content/node/:nodeId/listAtom, ezpRestAtomController, collection ), new ezcMvcRailsRoute( /content/node/:nodeId/list, ezpRestContentController, list ), new ezcMvcRailsRoute( /content/node/:nodeId, ezpRestContentController, viewContent ), new ezcMvcRailsRoute( /content/node/:nodeId/fields, ezpRestContentController, viewFields ), new ezcMvcRailsRoute( /content/node/:nodeId/field/:fieldIdentifier, ezpRestContentController, viewFie new ezcMvcRailsRoute( /content/object/:objectId, ezpRestContentController, viewContent ), new ezcMvcRailsRoute( /content/object/:objectId/fields, ezpRestContentController, viewFields ), new ezcMvcRailsRoute( /content/object/:objectId/field/:fieldIdentifier, ezpRestContentController, vie new ezpRestVersionedRoute( new ezcMvcRailsRoute( /foo, myController, myActionOne ), 1 ), new ezpRestVersionedRoute( new ezcMvcRailsRoute( e/foo, myController2 or myControlerWhichExtendsmyContr myBetterAndScalingAction ), 2 ), ); return ezcMvcRouter::prefix( /api, $routes ); } } Presenter: Ole Marius Smestad 27.01.2011 48mandag 31. januar 2011 48
  • Route setup 2 class ezpRestRouter extends ezcMvcRouter { public function createRoutes() { $providerRoutes = ezpRestProvider::getProvider( ezpRestPrefixFilterInterface::getApiProviderName() )- >getRoutes(); $routes = array( new ezpMvcRailsRoute( /fatal, ezpRestErrorController, show ), new ezpMvcRailsRoute( /http-basic-auth, ezpRestAuthController, basicAuth ), new ezpMvcRailsRoute( /login/oauth, ezpRestAuthController, oauthRequired ), new ezpMvcRailsRoute( /oauth/token, ezpRestOauthTokenController, handleRequest), // ezpRestVersionedRoute( $route, $version ) // $version == 1 should be the same as if the only the $route had been present new ezpRestVersionedRoute( new ezpMvcRailsRoute( /foo, myController, myActionOne ), 1 ), new ezpRestVersionedRoute( new ezpMvcRailsRoute( /foo, myController, myActionOneBetter ), 2 ), ); return ezcMvcRouter::prefix( /api, array_merge( $providerRoutes, $routes ) ); } } Presenter: Ole Marius Smestad 27.01.2011 49mandag 31. januar 2011 49
  • Protecting your resources 50mandag 31. januar 2011 50
  • Authentication OAuth 2.0 Presenter: Ole Marius Smestad 27.01.2011 51mandag 31. januar 2011 51
  • Authentication Basic auth Presenter: Ole Marius Smestad 27.01.2011 52mandag 31. januar 2011 52
  • Other security related options Require HTTPS (a requirement of OAuth) Decide which auth filter to use Presenter: Ole Marius Smestad 27.01.2011 53mandag 31. januar 2011 53
  • Summary 54mandag 31. januar 2011 54
  • Summary Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Summary Comes with the next release Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Summary Comes with the next release Gives access to existing content in a systematic way Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Summary Comes with the next release Gives access to existing content in a systematic way Output of content can be tweaked Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Summary Comes with the next release Gives access to existing content in a systematic way Output of content can be tweaked Is extendible through eZ Market extensions Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Summary Comes with the next release Gives access to existing content in a systematic way Output of content can be tweaked Is extendible through eZ Market extensions API is versioned Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Summary Comes with the next release Gives access to existing content in a systematic way Output of content can be tweaked Is extendible through eZ Market extensions API is versioned Control of BC Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Summary Comes with the next release Gives access to existing content in a systematic way Output of content can be tweaked Is extendible through eZ Market extensions API is versioned Control of BC Control of already rolled out API clients Presenter: Ole Marius Smestad 27.01.2011 55mandag 31. januar 2011 55
  • Questions? Presenter: Ole Marius Smestad 27.01.2011 56mandag 31. januar 2011 56
  • Possibility for more Q&A at the barcamp Presenter: Ole Marius Smestad 27.01.2011 57mandag 31. januar 2011 57
  • The end Thank you for listening Presenter: Ole Marius Smestad 27.01.2011 58mandag 31. januar 2011 58
  • The end github.com/ezsystems/ezp_rest Presenter: Ole Marius Smestad 27.01.2011 59mandag 31. januar 2011 59