SlideShare a Scribd company logo
Using eZ Platform in an API eraUsing eZ Platform in an API era
The time for monolithic applications is far gone. Now developers are
building solutions by assembling applications and services of all kinds and in
all ways.
We'll show you how eZ Platform embraces the modern way of building
applications by interacting with its Content Repository using
Public (PHP) API, REST API and GraphQL.
rtrand Dunogier
ps://github.com/bdunogier
ps://twitter.com/bdunogier
Andrew Lo
https://github.com/alo
https://twitter.com/andrew_
Public APIPublic API
How and why use it, BCHow and why use it, BC
promise explainedpromise explained
What is an API?What is an API?
API - Application Programming Interface - is a set of
well defined and maintained methods for building
application software.
eZ Platform Public API:eZ Platform Public API:
is a PHP API, grouped into Services with methods,
allowing Content Repository manipulation,
is provided by ezpublish-kernel package via
the interfaces in eZPublishAPI PHP
namespace.
What belongs to eZ Platform APIWhat belongs to eZ Platform API
Repository Services defined by interfaces in the
eZPublishAPIRepository namespace.
Value Objects defined in the
eZPublishAPIRepositoryValues
namespace.
Other interfaces defined in the
eZPublishAPIRepository namespace.
What does NOT belong toWhat does NOT belong to
eZ Platform APIeZ Platform API
Twig templates.
Database schema (though there is still a separate
BC promise for that).
Anything located in eZPublishCore
namespace.
Available Repository Services:Available Repository Services:
- Content Service.
- Location Service.
- Content Service.
- Permission Resolver.
- Field Type Service.
- Language Service.
- Object State Service.
- Role Service.
- Search Service.
- Section Service.
- Trash Service.
- URL Service
- URL Alias Service.
- User Service.
- Bookmark Service.
Accessing Public API ServicesAccessing Public API Services
Getting Content Service:
in a Symfony Container-aware class:
in a Controller extending
eZBundleEzPublishCoreBundleControlle
(not recommended):
/** @var SymfonyComponentDependencyInjectionContainerInterface
$repository = $container->get('ezpublish.api.repository');
/** @var eZPublishAPIRepositoryContentService $contentService
$contentService = $repository->getContentService();
/** @var eZPublishAPIRepositoryContentService $contentService
$contentService = $this->getRepository()->getContentService();
Getting Content Service:
via Repository injected into Symfony service:
by injecting specific Repository service definition:
AppMyService:
- '@ezpublish.api.repository'
AppMyService:
- '@ezpublish.api.service.content'
Why use an API?Why use an API?
Any changes to application state (mostly database
operations changing state of Content) are
maintained and supported.
It ensures all necessary layers (e.g. cache) are
properly handled by the Content Framework.
Has a Backward Compatiblity promise on usage
(for a Consumer).
Semantic VersioningSemantic Versioning
eZ Platform packages, including
ezpublish-kernel follow the SemVer version
numbering convention:
X.Y.Z (e.g. 2.1.1)
where:
X is major version (release).
Y is minor version.
Z is patch version.
For more information see .https://semver.org/
BC promise (X.Y.Z)BC promise (X.Y.Z)
Backward Compatibility promise is related mostly to
changes between minor (Y) versions.
Any minor release Y will not break existing code
written for major version X.
eZ Platform APIeZ Platform API
We ensure that any usage of API from the Consumer
point of view will work across any minor (Y) release.
composer.json:
{
"require": {
"ezsystems/ezpublish-kernel": "^7.1"
}
}
Examples of BC guaranteedExamples of BC guaranteed
usages:usages:
Backward Compatibility is guaranteed for:
class MyService
{
/** @var eZPublishAPIRepositoryContentService */
private $contentService;
public function doSomething()
{
// ...
$this->contentService->publishVersion($versionInfo);
// ...
}
}
Sometimes there is no other way than to use code
for which there is no BC guarantee.
What to do?
Unit-Test it!
Unit testing custom unsupported implementationsUnit testing custom unsupported implementations
composer.json:
{
"require": {
"ezsystems/ezpublish-kernel": "^7.1@dev"
}
}
use PHPUnitFrameworkTestCase;
use eZPublishCoreSomething;
class ClassUsingSomethingTest extends TestCase
{
public function testSomething()
{
$class = new MyClassUsingSomething();
// ...
$class->doSomething();
// ...
}
}
REST APIREST API
verbs, media types,verbs, media types,
response formatsresponse formats
REST APIREST API
Remote API implemented over HTTP protocol.
Reflects Public (PHP) API
Allows manipulating eZ Platform: Content, Content
Types, Locations, Content Relations, Object States,
URL aliases, Users and their permissions (Roles
and policies).
Exposes Search Service (via /views endpoint).
Uses Repository permissions (by default every
request is done as Anonymous user).
Is NOT SiteAccess-aware.
DocumentationDocumentation
Currently available at:
Will be moved to the Developer Documentation
( )
https://github.com/ezsystems/ezpublish-
kernel/blob/v7.1.1/doc/specifications/rest/REST-
API-V2.rst
http://doc.ezplatform.com
REST API:REST API:
is available for every eZ Platform installation at the
prefix /api/ezp/v2,
supports HTTP methods (verbs):
GET,
POST,
COPY,
PATCH,
DELETE,
PUBLISH,
OPTIONS.
allows to use X-Http-Method-override header
if a web server doesn't allow all mentioned
methods,
supports uniformly XML and JSON request
payloads and responses.
Expects in most cases HTTP headers:
Cookie,
X-CSRF-Token (for requests modifying state of
the system),
Accepts (with expected by a client media type
and format) - to control output,
Content-Type (with provided by a client media
type and format) - to control input.
X Siteaccess (to provide SiteAccess name, if
needed).
The Simplest REST API HTTP requestThe Simplest REST API HTTP request
returns Root response:
GET /api/ezp/v2 HTTP/1.1
Host: www.example.net
<?xml version="1.0" encoding="UTF-8"?>
<Root media-type="application/vnd.ez.api.Root+xml">
<content media-type="" href="/api/ezp/v2/content/objects"/>
<contentByRemoteId media-type="" href="/api/ezp/v2/content/ob
<contentTypes media-type="application/vnd.ez.api.ContentTypeI
<contentTypeByIdentifier media-type="" href="/api/ezp/v2/cont
<contentTypeGroups media-type="application/vnd.ez.api.Content
<contentTypeGroupByIdentifier media-type="" href="/api/ezp/v2
<users media-type="application/vnd.ez.api.UserRefList+xml" hr
<usersByRoleId media-type="application/vnd.ez.api.UserRefList
<usersByRemoteId media-type="application/vnd.ez.api.UserRefLi
<usersByEmail media-type="application/vnd.ez.api.UserRefList+x
<usersByLogin media-type="application/vnd.ez.api.UserRefList+x
<roles media-type="application/vnd.ez.api.RoleList+xml" href=
<rootLocation media-type="application/vnd.ez.api.Location+xml
<rootUserGroup media-type="application/vnd ez api UserGroup+xm
Creating REST sessionCreating REST session
Request:
POST /user/sessions HTTP/1.1
Host: www.example.net
Accept: application/vnd.ez.api.Session+xml
Content-Type: application/vnd.ez.api.SessionInput+xml
<?xml version="1.0" encoding="UTF-8"?>
<SessionInput>
<login>admin</login>
<password>secret</password>
</SessionInput>
Response:
HTTP/1.1 201 Created
Location: /user/sessions/go327ij2cirpo59pb6rrv2a4el2
Set-Cookie: eZSSID=go327ij2cirpo59pb6rrv2a4el2; domain=.example.n
Content-Type: application/vnd.ez.api.Session+xml
<?xml version="1.0" encoding="UTF-8"?>
<Session href="/user/sessions/sessionID" media-type="application/v
<name>eZSSID</name>
<identifier>go327ij2cirpo59pb6rrv2a4el2</identifier>
<csrfToken>23lkneri34ijajedfw39orj3j93</csrfToken>
<User href="/user/users/14" media-type="vnd.ez.api.User+xml"/>
</Session>
Creating REST session with mixedCreating REST session with mixed
input and output formatsinput and output formats
Request:
POST /user/sessions HTTP/1.1
Host: www.example.net
Accept: application/vnd.ez.api.Session+json
Content-Type: application/vnd.ez.api.SessionInput+xml
<?xml version="1.0" encoding="UTF-8"?>
<SessionInput>
<login>admin</login>
<password>secret</password>
</SessionInput>
Response:
HTTP/1.1 201 Created
Location: /user/sessions/go327ij2cirpo59pb6rrv2a4el2
Set-Cookie: eZSSID=go327ij2cirpo59pb6rrv2a4el2; domain=.example.n
Content-Type: application/vnd.ez.api.Session+json
{
"Session": {
"name": "eZSSID",
"identifier": "go327ij2cirpo59pb6rrv2a4el2",
"csrfToken": "23lkneri34ijajedfw39orj3j93",
"User": {
"_href": "/user/users/14",
"_media-type": "application/vnd.ez.api.User+json"
}
}
}
Search Service exampleSearch Service example
search Service expects Criterions, which makes
request complicated,
hence, it requires POST and that implies it requires
X-CSRF-Token header also.
Request:
POST /api/ezp/v2/views HTTP/1.1
Host: www.example.net
Content-Type: application/vnd.ez.api.ViewInput+xml; version=1.1
Accept: application/vnd.ez.api.Version+json
{
"ViewInput": {
"identifier": "my-unique-identifier",
"public": false,
"LocationQuery": {
"Criteria": {},
"FacetBuilders": {},
"SortClauses": {
"LocationPriority": "ascending"
},
"Filter": {
Response:
{
"View": {
"_media-type": "application/vnd.ez.api.View+json",
"_href": "/api/ezp/v2/views/subitems-load-location-2",
"identifier": "subitems-load-location-2",
"Query": {
"_media-type": "application/vnd.ez.api.Query+json"
},
"Result": {
"_media-type": "application/vnd.ez.api.ViewResult+jso
"_href": "/api/ezp/v2/views/subitems-load-location-2/
"count": 20,
"time": 0.0048329830169677734,
"timedOut": false,
"maxScore": null,
"searchHits": {
Platform REST APIPlatform REST API
Present, time anomaliesPresent, time anomalies
and futureand future
Past & presentPast & present
REST API has not been our focus since 1.0.
Stabilizing
Catching up on missing features
v2 won't receive significant improvements
Time anomaliesTime anomalies
GraphQL prototypeGraphQL prototype
GraphQL primerGraphQL primer
Query language created by Facebook
Strongly typed
Allows you to get exactly what you query
Reduces number of queries, a defect of the v2
REST API
{
hero {
name
# Queries can have comments!
friends {
name
}
}
}
{
"data": {
"hero":
{
"name": "R2-D2",
"friends": [
{
"name": "Luke Skywalker"
},
{
"name": "Leia Organa"
}
]
}
}
}
The prototypeThe prototype
Based on and
.
bdunogier/ezplatform-graphql-bundle
webonyx/graphql-php
overblog/graphqlbundle
Is it good ?Is it good ?
Yes.Yes.
More ?More ?
Surprisingly easy to implement
Great usability
List all content types, with field definitions and
types
Types can be inspected when browsing
Browsing content is really convenient
Flexible FieldTypeFlexible FieldType
GraphQL Interfaces ... on InterfaceName {
InterfaceSpecificField }
Interface per fieldtype
Variations of an image
Converted richtext
Direct access to relations
Geo coordinates from location
Fitting YOUR content modelFitting YOUR content model
We could go even further:
{
contentModel {
article {
name { text }
intro { html5 }
}
place {
name { text }
location { address latitude longitude }
}
}
}
(one last time)
LimitationsLimitations
Limited to reading, no writing (mutations)
Not adapted to managing content
Can apply to lightweight application use-cases
comments
ratings
Not optimised
FutureFuture
Rework will have to happen one day
REST V3: API Platform ?REST V3: API Platform ?
Centered around entities and operations on those
Our entities are value objects
Uses Symfony Serialization
Very well maintained
Modern formats, HATOAS
GraphQL (using webonyx)
Schema.org
Dynamically self-documented (Swagger/OpenAPI)
Built to be re-used by your own code
Slides are available at:
https://alongosz.github.io/ezconf2018-api/

More Related Content

What's hot

Reviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix MeschbergerReviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix Meschberger
mfrancis
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
Ido Flatow
 
Echi Converter Presentation External
Echi Converter Presentation ExternalEchi Converter Presentation External
Echi Converter Presentation External
guestc3b49e
 
This is how we REST
This is how we RESTThis is how we REST
This is how we REST
ColdFusionConference
 
Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2
Sergii Shymko
 
Day02 a pi.
Day02   a pi.Day02   a pi.
Day02 a pi.
ABDEL RAHMAN KARIM
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
Eyal Vardi
 
ColdFusion Internals
ColdFusion InternalsColdFusion Internals
ColdFusion Internals
ColdFusionConference
 
Java servlets and CGI
Java servlets and CGIJava servlets and CGI
Java servlets and CGI
lavanya marichamy
 
Composer The Right Way - 010PHP
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHP
Rafael Dohms
 
Servicemix4.5.0
Servicemix4.5.0Servicemix4.5.0
Servicemix4.5.0
manojkumar024
 
Browser Serving Your We Application Security - ZendCon 2017
Browser Serving Your We Application Security - ZendCon 2017Browser Serving Your We Application Security - ZendCon 2017
Browser Serving Your We Application Security - ZendCon 2017
Philippe Gamache
 
Amsterdam php create a restful api
Amsterdam php create a restful apiAmsterdam php create a restful api
Amsterdam php create a restful apiceeram
 
Fuse technology-2015
Fuse technology-2015Fuse technology-2015
Fuse technology-2015
Charles Moulliard
 
Restful API's with ColdFusion
Restful API's with ColdFusionRestful API's with ColdFusion
Restful API's with ColdFusion
ColdFusionConference
 
Server-side Java Programming
Server-side Java ProgrammingServer-side Java Programming
Server-side Java Programming
Chris Schalk
 
Composer the right way - NomadPHP
Composer the right way - NomadPHPComposer the right way - NomadPHP
Composer the right way - NomadPHP
Rafael Dohms
 
oVirt UI Plugin Infrastructure and the oVirt-Foreman plugin
oVirt UI Plugin Infrastructure and the oVirt-Foreman pluginoVirt UI Plugin Infrastructure and the oVirt-Foreman plugin
oVirt UI Plugin Infrastructure and the oVirt-Foreman plugin
Oved Ourfali
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with ComposerJason Grimes
 

What's hot (20)

Servlet
ServletServlet
Servlet
 
Reviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix MeschbergerReviving the HTTP Service - Felix Meschberger
Reviving the HTTP Service - Felix Meschberger
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 
Echi Converter Presentation External
Echi Converter Presentation ExternalEchi Converter Presentation External
Echi Converter Presentation External
 
This is how we REST
This is how we RESTThis is how we REST
This is how we REST
 
Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2Composer for Magento 1.x and Magento 2
Composer for Magento 1.x and Magento 2
 
Day02 a pi.
Day02   a pi.Day02   a pi.
Day02 a pi.
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
 
ColdFusion Internals
ColdFusion InternalsColdFusion Internals
ColdFusion Internals
 
Java servlets and CGI
Java servlets and CGIJava servlets and CGI
Java servlets and CGI
 
Composer The Right Way - 010PHP
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHP
 
Servicemix4.5.0
Servicemix4.5.0Servicemix4.5.0
Servicemix4.5.0
 
Browser Serving Your We Application Security - ZendCon 2017
Browser Serving Your We Application Security - ZendCon 2017Browser Serving Your We Application Security - ZendCon 2017
Browser Serving Your We Application Security - ZendCon 2017
 
Amsterdam php create a restful api
Amsterdam php create a restful apiAmsterdam php create a restful api
Amsterdam php create a restful api
 
Fuse technology-2015
Fuse technology-2015Fuse technology-2015
Fuse technology-2015
 
Restful API's with ColdFusion
Restful API's with ColdFusionRestful API's with ColdFusion
Restful API's with ColdFusion
 
Server-side Java Programming
Server-side Java ProgrammingServer-side Java Programming
Server-side Java Programming
 
Composer the right way - NomadPHP
Composer the right way - NomadPHPComposer the right way - NomadPHP
Composer the right way - NomadPHP
 
oVirt UI Plugin Infrastructure and the oVirt-Foreman plugin
oVirt UI Plugin Infrastructure and the oVirt-Foreman pluginoVirt UI Plugin Infrastructure and the oVirt-Foreman plugin
oVirt UI Plugin Infrastructure and the oVirt-Foreman plugin
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 

Similar to Using eZ Platform in an API Era

LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST API
stephenbhadran
 
Weekly Tech Session
Weekly Tech SessionWeekly Tech Session
Weekly Tech Session
Pravin Vaja
 
eZ Publish REST API v2
eZ Publish REST API v2eZ Publish REST API v2
eZ Publish REST API v2
Bertrand Dunogier
 
Web Server-Side Programming Techniques
Web Server-Side Programming TechniquesWeb Server-Side Programming Techniques
Web Server-Side Programming Techniques
guest8899ec02
 
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and ScalaWriting highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
jfarcand
 
Building Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJs
Srdjan Strbanovic
 
An Introduction to Websphere sMash for PHP Programmers
An Introduction to Websphere sMash for PHP ProgrammersAn Introduction to Websphere sMash for PHP Programmers
An Introduction to Websphere sMash for PHP Programmers
jphl
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
QAware GmbH
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
Sébastien Morel
 
RESTful API-centric Universe
RESTful API-centric UniverseRESTful API-centric Universe
RESTful API-centric Universe
Tihomir Opačić
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
Minal Maniar
 
REST Development made Easy with ColdFusion Aether
REST Development made Easy with ColdFusion AetherREST Development made Easy with ColdFusion Aether
REST Development made Easy with ColdFusion Aether
Pavan Kumar
 
Running Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic BeanstalkRunning Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic Beanstalk
Amazon Web Services
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Amazon Web Services
 
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
Jerome Louvel
 
Web Apps atop a Content Repository
Web Apps atop a Content RepositoryWeb Apps atop a Content Repository
Web Apps atop a Content Repository
Gabriel Walt
 

Similar to Using eZ Platform in an API Era (20)

LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST API
 
Weekly Tech Session
Weekly Tech SessionWeekly Tech Session
Weekly Tech Session
 
eZ Publish REST API v2
eZ Publish REST API v2eZ Publish REST API v2
eZ Publish REST API v2
 
E zsc2012 rest-api-v2
E zsc2012 rest-api-v2E zsc2012 rest-api-v2
E zsc2012 rest-api-v2
 
Web Server-Side Programming Techniques
Web Server-Side Programming TechniquesWeb Server-Side Programming Techniques
Web Server-Side Programming Techniques
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and ScalaWriting highly scalable WebSocket using the Atmosphere Framework and Scala
Writing highly scalable WebSocket using the Atmosphere Framework and Scala
 
Building Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJs
 
An Introduction to Websphere sMash for PHP Programmers
An Introduction to Websphere sMash for PHP ProgrammersAn Introduction to Websphere sMash for PHP Programmers
An Introduction to Websphere sMash for PHP Programmers
 
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
 
Unleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ PlatformUnleash your Symfony projects with eZ Platform
Unleash your Symfony projects with eZ Platform
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
RESTful API-centric Universe
RESTful API-centric UniverseRESTful API-centric Universe
RESTful API-centric Universe
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
REST Development made Easy with ColdFusion Aether
REST Development made Easy with ColdFusion AetherREST Development made Easy with ColdFusion Aether
REST Development made Easy with ColdFusion Aether
 
Running Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic BeanstalkRunning Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic Beanstalk
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
 
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
20140527 - APIcon SF - Workshop #2 - Document and manage Java-based web APIs
 
Web Apps atop a Content Repository
Web Apps atop a Content RepositoryWeb Apps atop a Content Repository
Web Apps atop a Content Repository
 

More from eZ Systems

A unified platform to build Digital Experience from Content to Commerce to Pe...
A unified platform to build Digital Experience from Content to Commerce to Pe...A unified platform to build Digital Experience from Content to Commerce to Pe...
A unified platform to build Digital Experience from Content to Commerce to Pe...
eZ Systems
 
"Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e...
"Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e..."Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e...
"Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e...
eZ Systems
 
"How Crédit Agricole and IT-CE managed their digital transformation thanks to...
"How Crédit Agricole and IT-CE managed their digital transformation thanks to..."How Crédit Agricole and IT-CE managed their digital transformation thanks to...
"How Crédit Agricole and IT-CE managed their digital transformation thanks to...
eZ Systems
 
The rise of Digital Experience Platforms
The rise of Digital Experience PlatformsThe rise of Digital Experience Platforms
The rise of Digital Experience Platforms
eZ Systems
 
"How to deliver remarkable digital experiences to customers?"
"How to deliver remarkable digital experiences to customers?""How to deliver remarkable digital experiences to customers?"
"How to deliver remarkable digital experiences to customers?"
eZ Systems
 
Keynote eZ Roadshow & Diginight 2019 - oslo
Keynote eZ Roadshow & Diginight 2019 - osloKeynote eZ Roadshow & Diginight 2019 - oslo
Keynote eZ Roadshow & Diginight 2019 - oslo
eZ Systems
 
Symfony 4.0 + - Track Technique eZ Roadshow 2019 - PARIS
Symfony 4.0 + - Track Technique eZ Roadshow 2019 - PARISSymfony 4.0 + - Track Technique eZ Roadshow 2019 - PARIS
Symfony 4.0 + - Track Technique eZ Roadshow 2019 - PARIS
eZ Systems
 
Brochure eZ Platform DXP
Brochure eZ Platform DXPBrochure eZ Platform DXP
Brochure eZ Platform DXP
eZ Systems
 
[Webinar] Discover eZ platform v2.4
[Webinar]  Discover eZ platform v2.4[Webinar]  Discover eZ platform v2.4
[Webinar] Discover eZ platform v2.4
eZ Systems
 
Community webinar discover e z platform v2.3 (9.10.2018)
Community webinar   discover e z platform v2.3 (9.10.2018)Community webinar   discover e z platform v2.3 (9.10.2018)
Community webinar discover e z platform v2.3 (9.10.2018)
eZ Systems
 
Symfony Under the Hood
Symfony Under the HoodSymfony Under the Hood
Symfony Under the Hood
eZ Systems
 
eZ in the Year Ahead
eZ in the Year AheadeZ in the Year Ahead
eZ in the Year Ahead
eZ Systems
 
Personalization on eZ Platform v2
Personalization on eZ Platform v2Personalization on eZ Platform v2
Personalization on eZ Platform v2
eZ Systems
 
Choose the eZ Universe for Your Web Galaxy
Choose the eZ Universe for Your Web GalaxyChoose the eZ Universe for Your Web Galaxy
Choose the eZ Universe for Your Web Galaxy
eZ Systems
 
Extending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReactExtending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and React
eZ Systems
 
A Roadmap to Becoming Your Customer’s Information Hub
A Roadmap to Becoming Your Customer’s Information HubA Roadmap to Becoming Your Customer’s Information Hub
A Roadmap to Becoming Your Customer’s Information Hub
eZ Systems
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Systems
 
GDPR in the Digital World
GDPR in the Digital WorldGDPR in the Digital World
GDPR in the Digital World
eZ Systems
 
When content transforms your customer experience
When content transforms your customer experienceWhen content transforms your customer experience
When content transforms your customer experience
eZ Systems
 
Connectors Panel Discussion
Connectors Panel DiscussionConnectors Panel Discussion
Connectors Panel Discussion
eZ Systems
 

More from eZ Systems (20)

A unified platform to build Digital Experience from Content to Commerce to Pe...
A unified platform to build Digital Experience from Content to Commerce to Pe...A unified platform to build Digital Experience from Content to Commerce to Pe...
A unified platform to build Digital Experience from Content to Commerce to Pe...
 
"Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e...
"Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e..."Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e...
"Reconociendo al cliente personalizando su experiencia" - Andorra Turisme - e...
 
"How Crédit Agricole and IT-CE managed their digital transformation thanks to...
"How Crédit Agricole and IT-CE managed their digital transformation thanks to..."How Crédit Agricole and IT-CE managed their digital transformation thanks to...
"How Crédit Agricole and IT-CE managed their digital transformation thanks to...
 
The rise of Digital Experience Platforms
The rise of Digital Experience PlatformsThe rise of Digital Experience Platforms
The rise of Digital Experience Platforms
 
"How to deliver remarkable digital experiences to customers?"
"How to deliver remarkable digital experiences to customers?""How to deliver remarkable digital experiences to customers?"
"How to deliver remarkable digital experiences to customers?"
 
Keynote eZ Roadshow & Diginight 2019 - oslo
Keynote eZ Roadshow & Diginight 2019 - osloKeynote eZ Roadshow & Diginight 2019 - oslo
Keynote eZ Roadshow & Diginight 2019 - oslo
 
Symfony 4.0 + - Track Technique eZ Roadshow 2019 - PARIS
Symfony 4.0 + - Track Technique eZ Roadshow 2019 - PARISSymfony 4.0 + - Track Technique eZ Roadshow 2019 - PARIS
Symfony 4.0 + - Track Technique eZ Roadshow 2019 - PARIS
 
Brochure eZ Platform DXP
Brochure eZ Platform DXPBrochure eZ Platform DXP
Brochure eZ Platform DXP
 
[Webinar] Discover eZ platform v2.4
[Webinar]  Discover eZ platform v2.4[Webinar]  Discover eZ platform v2.4
[Webinar] Discover eZ platform v2.4
 
Community webinar discover e z platform v2.3 (9.10.2018)
Community webinar   discover e z platform v2.3 (9.10.2018)Community webinar   discover e z platform v2.3 (9.10.2018)
Community webinar discover e z platform v2.3 (9.10.2018)
 
Symfony Under the Hood
Symfony Under the HoodSymfony Under the Hood
Symfony Under the Hood
 
eZ in the Year Ahead
eZ in the Year AheadeZ in the Year Ahead
eZ in the Year Ahead
 
Personalization on eZ Platform v2
Personalization on eZ Platform v2Personalization on eZ Platform v2
Personalization on eZ Platform v2
 
Choose the eZ Universe for Your Web Galaxy
Choose the eZ Universe for Your Web GalaxyChoose the eZ Universe for Your Web Galaxy
Choose the eZ Universe for Your Web Galaxy
 
Extending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and ReactExtending eZ Platform v2 with Symfony and React
Extending eZ Platform v2 with Symfony and React
 
A Roadmap to Becoming Your Customer’s Information Hub
A Roadmap to Becoming Your Customer’s Information HubA Roadmap to Becoming Your Customer’s Information Hub
A Roadmap to Becoming Your Customer’s Information Hub
 
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
eZ Platform Cloud and eZ Launchpad: Don’t Host, Don’t Deploy, Don’t Install—J...
 
GDPR in the Digital World
GDPR in the Digital WorldGDPR in the Digital World
GDPR in the Digital World
 
When content transforms your customer experience
When content transforms your customer experienceWhen content transforms your customer experience
When content transforms your customer experience
 
Connectors Panel Discussion
Connectors Panel DiscussionConnectors Panel Discussion
Connectors Panel Discussion
 

Recently uploaded

Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
VivekSinghShekhawat2
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
GTProductions1
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
Javier Lasa
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 

Recently uploaded (20)

Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 

Using eZ Platform in an API Era

  • 1. Using eZ Platform in an API eraUsing eZ Platform in an API era The time for monolithic applications is far gone. Now developers are building solutions by assembling applications and services of all kinds and in all ways. We'll show you how eZ Platform embraces the modern way of building applications by interacting with its Content Repository using Public (PHP) API, REST API and GraphQL. rtrand Dunogier ps://github.com/bdunogier ps://twitter.com/bdunogier Andrew Lo https://github.com/alo https://twitter.com/andrew_
  • 2. Public APIPublic API How and why use it, BCHow and why use it, BC promise explainedpromise explained
  • 3. What is an API?What is an API? API - Application Programming Interface - is a set of well defined and maintained methods for building application software. eZ Platform Public API:eZ Platform Public API: is a PHP API, grouped into Services with methods, allowing Content Repository manipulation, is provided by ezpublish-kernel package via the interfaces in eZPublishAPI PHP namespace.
  • 4. What belongs to eZ Platform APIWhat belongs to eZ Platform API Repository Services defined by interfaces in the eZPublishAPIRepository namespace. Value Objects defined in the eZPublishAPIRepositoryValues namespace. Other interfaces defined in the eZPublishAPIRepository namespace.
  • 5. What does NOT belong toWhat does NOT belong to eZ Platform APIeZ Platform API Twig templates. Database schema (though there is still a separate BC promise for that). Anything located in eZPublishCore namespace.
  • 6. Available Repository Services:Available Repository Services: - Content Service. - Location Service. - Content Service. - Permission Resolver. - Field Type Service. - Language Service. - Object State Service. - Role Service. - Search Service. - Section Service. - Trash Service. - URL Service - URL Alias Service. - User Service. - Bookmark Service.
  • 7. Accessing Public API ServicesAccessing Public API Services Getting Content Service: in a Symfony Container-aware class: in a Controller extending eZBundleEzPublishCoreBundleControlle (not recommended): /** @var SymfonyComponentDependencyInjectionContainerInterface $repository = $container->get('ezpublish.api.repository'); /** @var eZPublishAPIRepositoryContentService $contentService $contentService = $repository->getContentService(); /** @var eZPublishAPIRepositoryContentService $contentService $contentService = $this->getRepository()->getContentService();
  • 8. Getting Content Service: via Repository injected into Symfony service: by injecting specific Repository service definition: AppMyService: - '@ezpublish.api.repository' AppMyService: - '@ezpublish.api.service.content'
  • 9. Why use an API?Why use an API? Any changes to application state (mostly database operations changing state of Content) are maintained and supported. It ensures all necessary layers (e.g. cache) are properly handled by the Content Framework. Has a Backward Compatiblity promise on usage (for a Consumer).
  • 10. Semantic VersioningSemantic Versioning eZ Platform packages, including ezpublish-kernel follow the SemVer version numbering convention: X.Y.Z (e.g. 2.1.1) where: X is major version (release). Y is minor version. Z is patch version. For more information see .https://semver.org/
  • 11. BC promise (X.Y.Z)BC promise (X.Y.Z) Backward Compatibility promise is related mostly to changes between minor (Y) versions. Any minor release Y will not break existing code written for major version X.
  • 12. eZ Platform APIeZ Platform API We ensure that any usage of API from the Consumer point of view will work across any minor (Y) release. composer.json: { "require": { "ezsystems/ezpublish-kernel": "^7.1" } }
  • 13. Examples of BC guaranteedExamples of BC guaranteed usages:usages: Backward Compatibility is guaranteed for: class MyService { /** @var eZPublishAPIRepositoryContentService */ private $contentService; public function doSomething() { // ... $this->contentService->publishVersion($versionInfo); // ... } }
  • 14. Sometimes there is no other way than to use code for which there is no BC guarantee. What to do? Unit-Test it!
  • 15. Unit testing custom unsupported implementationsUnit testing custom unsupported implementations composer.json: { "require": { "ezsystems/ezpublish-kernel": "^7.1@dev" } } use PHPUnitFrameworkTestCase; use eZPublishCoreSomething; class ClassUsingSomethingTest extends TestCase { public function testSomething() { $class = new MyClassUsingSomething(); // ... $class->doSomething(); // ... } }
  • 16. REST APIREST API verbs, media types,verbs, media types, response formatsresponse formats
  • 17. REST APIREST API Remote API implemented over HTTP protocol. Reflects Public (PHP) API Allows manipulating eZ Platform: Content, Content Types, Locations, Content Relations, Object States, URL aliases, Users and their permissions (Roles and policies). Exposes Search Service (via /views endpoint). Uses Repository permissions (by default every request is done as Anonymous user). Is NOT SiteAccess-aware.
  • 18. DocumentationDocumentation Currently available at: Will be moved to the Developer Documentation ( ) https://github.com/ezsystems/ezpublish- kernel/blob/v7.1.1/doc/specifications/rest/REST- API-V2.rst http://doc.ezplatform.com
  • 19. REST API:REST API: is available for every eZ Platform installation at the prefix /api/ezp/v2, supports HTTP methods (verbs): GET, POST, COPY, PATCH, DELETE, PUBLISH, OPTIONS.
  • 20. allows to use X-Http-Method-override header if a web server doesn't allow all mentioned methods, supports uniformly XML and JSON request payloads and responses. Expects in most cases HTTP headers: Cookie, X-CSRF-Token (for requests modifying state of the system), Accepts (with expected by a client media type and format) - to control output, Content-Type (with provided by a client media type and format) - to control input.
  • 21. X Siteaccess (to provide SiteAccess name, if needed).
  • 22. The Simplest REST API HTTP requestThe Simplest REST API HTTP request returns Root response: GET /api/ezp/v2 HTTP/1.1 Host: www.example.net
  • 23. <?xml version="1.0" encoding="UTF-8"?> <Root media-type="application/vnd.ez.api.Root+xml"> <content media-type="" href="/api/ezp/v2/content/objects"/> <contentByRemoteId media-type="" href="/api/ezp/v2/content/ob <contentTypes media-type="application/vnd.ez.api.ContentTypeI <contentTypeByIdentifier media-type="" href="/api/ezp/v2/cont <contentTypeGroups media-type="application/vnd.ez.api.Content <contentTypeGroupByIdentifier media-type="" href="/api/ezp/v2 <users media-type="application/vnd.ez.api.UserRefList+xml" hr <usersByRoleId media-type="application/vnd.ez.api.UserRefList <usersByRemoteId media-type="application/vnd.ez.api.UserRefLi <usersByEmail media-type="application/vnd.ez.api.UserRefList+x <usersByLogin media-type="application/vnd.ez.api.UserRefList+x <roles media-type="application/vnd.ez.api.RoleList+xml" href= <rootLocation media-type="application/vnd.ez.api.Location+xml <rootUserGroup media-type="application/vnd ez api UserGroup+xm
  • 24. Creating REST sessionCreating REST session Request: POST /user/sessions HTTP/1.1 Host: www.example.net Accept: application/vnd.ez.api.Session+xml Content-Type: application/vnd.ez.api.SessionInput+xml <?xml version="1.0" encoding="UTF-8"?> <SessionInput> <login>admin</login> <password>secret</password> </SessionInput>
  • 25. Response: HTTP/1.1 201 Created Location: /user/sessions/go327ij2cirpo59pb6rrv2a4el2 Set-Cookie: eZSSID=go327ij2cirpo59pb6rrv2a4el2; domain=.example.n Content-Type: application/vnd.ez.api.Session+xml <?xml version="1.0" encoding="UTF-8"?> <Session href="/user/sessions/sessionID" media-type="application/v <name>eZSSID</name> <identifier>go327ij2cirpo59pb6rrv2a4el2</identifier> <csrfToken>23lkneri34ijajedfw39orj3j93</csrfToken> <User href="/user/users/14" media-type="vnd.ez.api.User+xml"/> </Session>
  • 26. Creating REST session with mixedCreating REST session with mixed input and output formatsinput and output formats Request: POST /user/sessions HTTP/1.1 Host: www.example.net Accept: application/vnd.ez.api.Session+json Content-Type: application/vnd.ez.api.SessionInput+xml <?xml version="1.0" encoding="UTF-8"?> <SessionInput> <login>admin</login> <password>secret</password> </SessionInput>
  • 27. Response: HTTP/1.1 201 Created Location: /user/sessions/go327ij2cirpo59pb6rrv2a4el2 Set-Cookie: eZSSID=go327ij2cirpo59pb6rrv2a4el2; domain=.example.n Content-Type: application/vnd.ez.api.Session+json { "Session": { "name": "eZSSID", "identifier": "go327ij2cirpo59pb6rrv2a4el2", "csrfToken": "23lkneri34ijajedfw39orj3j93", "User": { "_href": "/user/users/14", "_media-type": "application/vnd.ez.api.User+json" } } }
  • 28. Search Service exampleSearch Service example search Service expects Criterions, which makes request complicated, hence, it requires POST and that implies it requires X-CSRF-Token header also.
  • 29. Request: POST /api/ezp/v2/views HTTP/1.1 Host: www.example.net Content-Type: application/vnd.ez.api.ViewInput+xml; version=1.1 Accept: application/vnd.ez.api.Version+json { "ViewInput": { "identifier": "my-unique-identifier", "public": false, "LocationQuery": { "Criteria": {}, "FacetBuilders": {}, "SortClauses": { "LocationPriority": "ascending" }, "Filter": {
  • 30. Response: { "View": { "_media-type": "application/vnd.ez.api.View+json", "_href": "/api/ezp/v2/views/subitems-load-location-2", "identifier": "subitems-load-location-2", "Query": { "_media-type": "application/vnd.ez.api.Query+json" }, "Result": { "_media-type": "application/vnd.ez.api.ViewResult+jso "_href": "/api/ezp/v2/views/subitems-load-location-2/ "count": 20, "time": 0.0048329830169677734, "timedOut": false, "maxScore": null, "searchHits": {
  • 31. Platform REST APIPlatform REST API Present, time anomaliesPresent, time anomalies and futureand future
  • 32. Past & presentPast & present REST API has not been our focus since 1.0. Stabilizing Catching up on missing features v2 won't receive significant improvements
  • 33. Time anomaliesTime anomalies GraphQL prototypeGraphQL prototype
  • 34. GraphQL primerGraphQL primer Query language created by Facebook Strongly typed Allows you to get exactly what you query Reduces number of queries, a defect of the v2 REST API
  • 35. { hero { name # Queries can have comments! friends { name } } }
  • 36. { "data": { "hero": { "name": "R2-D2", "friends": [ { "name": "Luke Skywalker" }, { "name": "Leia Organa" } ] } } }
  • 37. The prototypeThe prototype Based on and . bdunogier/ezplatform-graphql-bundle webonyx/graphql-php overblog/graphqlbundle
  • 38. Is it good ?Is it good ?
  • 40. More ?More ? Surprisingly easy to implement Great usability List all content types, with field definitions and types Types can be inspected when browsing Browsing content is really convenient
  • 41.
  • 42. Flexible FieldTypeFlexible FieldType GraphQL Interfaces ... on InterfaceName { InterfaceSpecificField } Interface per fieldtype Variations of an image Converted richtext Direct access to relations Geo coordinates from location
  • 43.
  • 44. Fitting YOUR content modelFitting YOUR content model We could go even further: { contentModel { article { name { text } intro { html5 } } place { name { text } location { address latitude longitude } } } }
  • 46. LimitationsLimitations Limited to reading, no writing (mutations) Not adapted to managing content Can apply to lightweight application use-cases comments ratings Not optimised
  • 47. FutureFuture Rework will have to happen one day
  • 48. REST V3: API Platform ?REST V3: API Platform ?
  • 49. Centered around entities and operations on those Our entities are value objects Uses Symfony Serialization
  • 50. Very well maintained Modern formats, HATOAS GraphQL (using webonyx) Schema.org Dynamically self-documented (Swagger/OpenAPI) Built to be re-used by your own code
  • 51. Slides are available at: https://alongosz.github.io/ezconf2018-api/