SlideShare a Scribd company logo
RESTful application with
Drupal 8
Concept / Overview / Demonstration / Happyness
Introduction
Digital agency established since
2008 in Mauritius
Recognized as one of the most
expert offshore web agencies in
Drupal
More than 150 projects in Drupal
Introduction
Technical Director at Esokia
10 years of experience in PHP
7 years of experience in Drupal
What is Drupal?
Free, community-built website development tool
Modular and extensible content management
Open source
Built on PHP
Created by Dries Buytaert
First release in January 2001
Drupal now
Drupal 8 released on November, 2015 (approx.)
Big architectural changes
Built with
About the
session
A little warm-up
An overview about Drupal 8 and this
new core capability to build RESTful
application. From a basic utilisation
to a more complexe use case, we
will made a global overview of
possible exploitation of Drupal 8
RESTful aspect.
Warm-up
Drupal 8 is the next main version of Drupal’s CMS, a quick overview and
presentation will be made for exposing the concept.
On the next topic, we will see what is REST and key concept about a RESTful
application, with basic exemple and application. A more advanced concept will
be see in the next topic, with a presentation about an utilisation of JavaScript to
use a Drupal 8 RESTful application and a more complex example with a
NodeJS / ExpressJS application.
RESTful?
REpresentational
State
Transfert
An application that implements the
REST architectural style is called a
RESTful application
REST Principle
Communicate over HTTP protocol
using HTTP verbs that web browsers
use between client and server
GET
PUT
DELETE
POST
PATCH
etc
REST Implementation - Two ways
GET → Retreive something
POST → Create something
DELETE → Delete something
PATCH → Update something
GET → Retrieve something
POST → Update something
DELETE → Delete something
PUT → Create something
What is REST in Drupal?
Make possible for other applications to read and update information on your
site via the Web.
REST is one of a number of different ways of making it available.
In contrast to other techniques such as SOAP or XML-RPC, REST encourages
developers to rely on HTTP methods (such as GET and POST) to operate on
"resources" (data managed by Drupal).
RESTful Web Service API
The RESTful Web Services API is new in Drupal 8.
For each REST resource, you can specify the supported verbs (i.e. GET,
POST…), and for each verb, you can specify the serialization formats &
authentication mechanisms.
In Drupal 8, there is a single central location to configure all REST resources
that a site exposes: rest.settings.yml.
A permission is generated for every resource + verb, users need this
permission to be able to interact with this REST resource.
GET
For reading content
entities.
Read-only method.
Considered as a safe method.
Results are automatically cached.
POST
For creating content
entities.
Some entities need a _links entry to
the user and / or to the referenced
entity.
Never POST a UUID (or node
ID/comment ID/…) as you create a
new entity.
Considered as an unsafe method.
Need a CSRF Token.
PATCH
For updading content
entities.
When PATCHing resources, only send
the changes.
Considered as an unsafe method.
Need a CSRF Token.
DELETE
For deleting content
entities.
Content-type header not necessary (no
request body).
Considered as an unsafe method.
Need a CSRF Token.
Basic Example
Read and write data from your Drupal installation with a couple of modules.
Requirements:
RESTful Web Services (rest)
Serialization (serialization)
Hypertext Application Language (hal)
HTTP Basic Authentication (basic_auth)
Core module to enable
REST UI interface
List of permissions for using REST
Basic example in action
Little
demonstration?
JS + D8 RESTful Web Services
Can be use with every kind of entities in Drupal 8 if they are exposed for REST.
Just implement an HTTP request and let’s go.
Easy to separate client and server.
Improve the client code’s portability.
Servers can be simpler and more scalable.
JQuery example
JQuery already loaded in Drupal
(JQuery 1.7)
Every Drupal 8 project can be easily
RESTful with client-server separation
GET / POST /PATCH / DELETE still
available
Advanced Example
Building a timesheet application in Drupal 8 with a separated front-end.
What we need?
A Drupal 8 installation with RESTful Web Services API
Something funny like NodeJS
ExpressJS or a similar framework
Requirements
LAMP Stack for the backend
Linux
Apache
MySQL
PHP
Requirements
MEAN Stack for the frontend
MongoDB
ExpressJS
AngularJS
NodeJS
Requirements
RESTful Web Services
Views
Field UI (nice to have)
REST UI (nice to have)
Drupal 8 installation
Live conding?
LAMP Stack
Be efficient: Google
Cloud + Bitnami is a good
combo! :-D
Good combo is a pre-installed
Drupal’s LAMP Stack.
MEAN Stack
Be efficient: Google
Cloud + Bitnami is a good
combo! :-D (really!)
NodeJS Locally
ExpressJS Locally
ExpressJS locally
Let’s try
Drupal:
● Content type
● Views
● Permissions
Remember to configure the
view for the REST Export!
Let’s try
ExpressJS
● Don’t forget to npm init before!
● And npm install express --save for dependencies
● You can add a template engine, add route with parameters, etc
Drupal <-> NodeJS
Need to install NPM Request
module
Load it in your Express App
Interact with Drupal!
Questions?
Thank you!

More Related Content

What's hot (8)

PPTX
Wordpress Custom Child theme
YouSaf HasSan
 
PDF
Drupal 8 and iOS - an Open Source App
littleMAS
 
PPTX
Oracle SQLcl: Formatting your Query Results
Jeff Smith
 
PDF
Drupal 8 Deep Dive: Plugin System
Acquia
 
PDF
Getting started with DSpace 7 REST API
4Science
 
PPTX
Dspace 7 presentation
mohamed Elzalabany
 
PPTX
Apache Hive authorization models
Thejas Nair
 
PDF
Elements_Content_Model_Overview.pdf
Jeff Smith
 
Wordpress Custom Child theme
YouSaf HasSan
 
Drupal 8 and iOS - an Open Source App
littleMAS
 
Oracle SQLcl: Formatting your Query Results
Jeff Smith
 
Drupal 8 Deep Dive: Plugin System
Acquia
 
Getting started with DSpace 7 REST API
4Science
 
Dspace 7 presentation
mohamed Elzalabany
 
Apache Hive authorization models
Thejas Nair
 
Elements_Content_Model_Overview.pdf
Jeff Smith
 

Viewers also liked (20)

PDF
Drupal 8: frontend development
sparkfabrik
 
PPT
An introduction to Google Analytics
Joris Roebben
 
PDF
Google Analytics 101 | 2015
Insivia
 
PDF
Paragraphs and the Fieldable Authoring Experience in Drupal 7
Peter Macinkovic
 
PDF
Bootstrap framework and drupal paragraphs
Jim Birch
 
PDF
Politische Ponerologie
MCExorzist
 
PDF
Muammar al-Gaddafi - Das Grüne Buch
MCExorzist
 
PDF
JS Class 2016
Yves-Emmanuel Jutard
 
PDF
Real History - The Bad War (english 115s)
MCExorzist
 
PDF
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
MCExorzist
 
PDF
Thomas Goodrich - Hellstorm The Death Of Nazi Germany
MCExorzist
 
PDF
JavaScript - The Universal Platform?
Jonas Bandi
 
PDF
Angela Merkel - Doktorarbeit
MCExorzist
 
PDF
Drupal 8: Forms
drubb
 
PDF
Cross-Platform Desktop Apps with Electron (JSConf UY)
David Neal
 
PDF
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
David Neal
 
PDF
Electron
Virginia Rodriguez
 
PDF
JavaScript and Desktop Apps - Introduction to Electron
Brainhub
 
PPT
Architecture of Drupal - Drupal Camp
Dipen Chaudhary
 
PDF
State of Search, Solr and Facets in Drupal 8 - Drupalcamp Belgium 2015
Dropsolid
 
Drupal 8: frontend development
sparkfabrik
 
An introduction to Google Analytics
Joris Roebben
 
Google Analytics 101 | 2015
Insivia
 
Paragraphs and the Fieldable Authoring Experience in Drupal 7
Peter Macinkovic
 
Bootstrap framework and drupal paragraphs
Jim Birch
 
Politische Ponerologie
MCExorzist
 
Muammar al-Gaddafi - Das Grüne Buch
MCExorzist
 
JS Class 2016
Yves-Emmanuel Jutard
 
Real History - The Bad War (english 115s)
MCExorzist
 
Gerd Honsik - Freispruch für Hitler - 1988 - 233S
MCExorzist
 
Thomas Goodrich - Hellstorm The Death Of Nazi Germany
MCExorzist
 
JavaScript - The Universal Platform?
Jonas Bandi
 
Angela Merkel - Doktorarbeit
MCExorzist
 
Drupal 8: Forms
drubb
 
Cross-Platform Desktop Apps with Electron (JSConf UY)
David Neal
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
David Neal
 
JavaScript and Desktop Apps - Introduction to Electron
Brainhub
 
Architecture of Drupal - Drupal Camp
Dipen Chaudhary
 
State of Search, Solr and Facets in Drupal 8 - Drupalcamp Belgium 2015
Dropsolid
 
Ad

Similar to RESTful application with Drupal 8 (20)

PPTX
RestFul Web Services In Drupal 8
Gajendra Sharma
 
PDF
Serving the Internet of Things (IoT) with Drupal - DrupalCon Barcelona 2015
Exove
 
PDF
REST Servers in Delphi XE Using DataSnap
Embarcadero Technologies
 
PPTX
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Pete Morano
 
PPTX
Unerstanding and Using RESTful APIs
SocialDevCamp Chicago
 
PDF
RESTful Web Services in Drupal7
bmeme
 
PDF
What Makes Drupal 8 so Great!
Drupal Durban
 
PDF
Serving the Internet of Things (IoT) with Drupal - DrupalCamp Baltics 2015:
Exove
 
PDF
REST full API Design
Christian Guenther
 
ODP
REST API Laravel
John Dave Decano
 
PPTX
Oleg Bogut - Decoupled Drupal: how to build stable solution with JSON:API, Re...
DrupalCamp Kyiv
 
PDF
RESTful applications: The why and how by Maikel Mardjan
Jexia
 
PPTX
Oracle REST Data Services
Chris Muir
 
PPTX
RESTful Web services in Drupal 8
valuebound
 
PDF
Restful web services_tutorial
philip75020
 
PPTX
RESTful Web Development with CakePHP
Andru Weir
 
PDF
Drupalcon Mumbai
Sumit Kataria
 
PDF
[drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5
DrupalDay
 
PDF
Unleash the power of HTTP with ASP.NET Web API
Filip W
 
PPTX
Drupal 8 preview_slideshow
Tee Malapela
 
RestFul Web Services In Drupal 8
Gajendra Sharma
 
Serving the Internet of Things (IoT) with Drupal - DrupalCon Barcelona 2015
Exove
 
REST Servers in Delphi XE Using DataSnap
Embarcadero Technologies
 
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Pete Morano
 
Unerstanding and Using RESTful APIs
SocialDevCamp Chicago
 
RESTful Web Services in Drupal7
bmeme
 
What Makes Drupal 8 so Great!
Drupal Durban
 
Serving the Internet of Things (IoT) with Drupal - DrupalCamp Baltics 2015:
Exove
 
REST full API Design
Christian Guenther
 
REST API Laravel
John Dave Decano
 
Oleg Bogut - Decoupled Drupal: how to build stable solution with JSON:API, Re...
DrupalCamp Kyiv
 
RESTful applications: The why and how by Maikel Mardjan
Jexia
 
Oracle REST Data Services
Chris Muir
 
RESTful Web services in Drupal 8
valuebound
 
Restful web services_tutorial
philip75020
 
RESTful Web Development with CakePHP
Andru Weir
 
Drupalcon Mumbai
Sumit Kataria
 
[drupalday2017] - Decoupled frontend con Drupal 8 e OpenUI 5
DrupalDay
 
Unleash the power of HTTP with ASP.NET Web API
Filip W
 
Drupal 8 preview_slideshow
Tee Malapela
 
Ad

Recently uploaded (20)

PDF
Digital burnout toolkit for youth workers and teachers
asociatiastart123
 
PPTX
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
PDF
BRKACI-1003 ACI Brownfield Migration - Real World Experiences and Best Practi...
fcesargonca
 
PPTX
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
PDF
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
PDF
BRKACI-1001 - Your First 7 Days of ACI.pdf
fcesargonca
 
PPTX
Metaphysics_Presentation_With_Visuals.pptx
erikjohnsales1
 
PDF
The Internet - By the numbers, presented at npNOG 11
APNIC
 
DOCX
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
PPTX
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 
PDF
BRKAPP-1102 - Proactive Network and Application Monitoring.pdf
fcesargonca
 
PPTX
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
PPTX
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
PDF
Enhancing Parental Roles in Protecting Children from Online Sexual Exploitati...
ICT Frame Magazine Pvt. Ltd.
 
PPTX
Networking_Essentials_version_3.0_-_Module_5.pptx
ryan622010
 
PPTX
Orchestrating things in Angular application
Peter Abraham
 
PDF
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
PDF
Boardroom AI: The Next 10 Moves | Cerebraix Talent Tech
ssuser73bdb11
 
PPTX
Networking_Essentials_version_3.0_-_Module_3.pptx
ryan622010
 
PPTX
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
Digital burnout toolkit for youth workers and teachers
asociatiastart123
 
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
BRKACI-1003 ACI Brownfield Migration - Real World Experiences and Best Practi...
fcesargonca
 
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
BRKACI-1001 - Your First 7 Days of ACI.pdf
fcesargonca
 
Metaphysics_Presentation_With_Visuals.pptx
erikjohnsales1
 
The Internet - By the numbers, presented at npNOG 11
APNIC
 
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 
BRKAPP-1102 - Proactive Network and Application Monitoring.pdf
fcesargonca
 
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
Enhancing Parental Roles in Protecting Children from Online Sexual Exploitati...
ICT Frame Magazine Pvt. Ltd.
 
Networking_Essentials_version_3.0_-_Module_5.pptx
ryan622010
 
Orchestrating things in Angular application
Peter Abraham
 
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
Boardroom AI: The Next 10 Moves | Cerebraix Talent Tech
ssuser73bdb11
 
Networking_Essentials_version_3.0_-_Module_3.pptx
ryan622010
 
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 

RESTful application with Drupal 8

  • 1. RESTful application with Drupal 8 Concept / Overview / Demonstration / Happyness
  • 2. Introduction Digital agency established since 2008 in Mauritius Recognized as one of the most expert offshore web agencies in Drupal More than 150 projects in Drupal
  • 3. Introduction Technical Director at Esokia 10 years of experience in PHP 7 years of experience in Drupal
  • 4. What is Drupal? Free, community-built website development tool Modular and extensible content management Open source Built on PHP Created by Dries Buytaert First release in January 2001
  • 5. Drupal now Drupal 8 released on November, 2015 (approx.) Big architectural changes Built with
  • 6. About the session A little warm-up An overview about Drupal 8 and this new core capability to build RESTful application. From a basic utilisation to a more complexe use case, we will made a global overview of possible exploitation of Drupal 8 RESTful aspect.
  • 7. Warm-up Drupal 8 is the next main version of Drupal’s CMS, a quick overview and presentation will be made for exposing the concept. On the next topic, we will see what is REST and key concept about a RESTful application, with basic exemple and application. A more advanced concept will be see in the next topic, with a presentation about an utilisation of JavaScript to use a Drupal 8 RESTful application and a more complex example with a NodeJS / ExpressJS application.
  • 8. RESTful? REpresentational State Transfert An application that implements the REST architectural style is called a RESTful application
  • 9. REST Principle Communicate over HTTP protocol using HTTP verbs that web browsers use between client and server GET PUT DELETE POST PATCH etc
  • 10. REST Implementation - Two ways GET → Retreive something POST → Create something DELETE → Delete something PATCH → Update something GET → Retrieve something POST → Update something DELETE → Delete something PUT → Create something
  • 11. What is REST in Drupal? Make possible for other applications to read and update information on your site via the Web. REST is one of a number of different ways of making it available. In contrast to other techniques such as SOAP or XML-RPC, REST encourages developers to rely on HTTP methods (such as GET and POST) to operate on "resources" (data managed by Drupal).
  • 12. RESTful Web Service API The RESTful Web Services API is new in Drupal 8. For each REST resource, you can specify the supported verbs (i.e. GET, POST…), and for each verb, you can specify the serialization formats & authentication mechanisms. In Drupal 8, there is a single central location to configure all REST resources that a site exposes: rest.settings.yml. A permission is generated for every resource + verb, users need this permission to be able to interact with this REST resource.
  • 13. GET For reading content entities. Read-only method. Considered as a safe method. Results are automatically cached.
  • 14. POST For creating content entities. Some entities need a _links entry to the user and / or to the referenced entity. Never POST a UUID (or node ID/comment ID/…) as you create a new entity. Considered as an unsafe method. Need a CSRF Token.
  • 15. PATCH For updading content entities. When PATCHing resources, only send the changes. Considered as an unsafe method. Need a CSRF Token.
  • 16. DELETE For deleting content entities. Content-type header not necessary (no request body). Considered as an unsafe method. Need a CSRF Token.
  • 17. Basic Example Read and write data from your Drupal installation with a couple of modules. Requirements: RESTful Web Services (rest) Serialization (serialization) Hypertext Application Language (hal) HTTP Basic Authentication (basic_auth)
  • 18. Core module to enable
  • 20. List of permissions for using REST
  • 23. JS + D8 RESTful Web Services Can be use with every kind of entities in Drupal 8 if they are exposed for REST. Just implement an HTTP request and let’s go. Easy to separate client and server. Improve the client code’s portability. Servers can be simpler and more scalable.
  • 24. JQuery example JQuery already loaded in Drupal (JQuery 1.7) Every Drupal 8 project can be easily RESTful with client-server separation GET / POST /PATCH / DELETE still available
  • 25. Advanced Example Building a timesheet application in Drupal 8 with a separated front-end. What we need? A Drupal 8 installation with RESTful Web Services API Something funny like NodeJS ExpressJS or a similar framework
  • 26. Requirements LAMP Stack for the backend Linux Apache MySQL PHP
  • 27. Requirements MEAN Stack for the frontend MongoDB ExpressJS AngularJS NodeJS
  • 28. Requirements RESTful Web Services Views Field UI (nice to have) REST UI (nice to have) Drupal 8 installation
  • 30. LAMP Stack Be efficient: Google Cloud + Bitnami is a good combo! :-D Good combo is a pre-installed Drupal’s LAMP Stack.
  • 31. MEAN Stack Be efficient: Google Cloud + Bitnami is a good combo! :-D (really!)
  • 35. Let’s try Drupal: ● Content type ● Views ● Permissions Remember to configure the view for the REST Export!
  • 36. Let’s try ExpressJS ● Don’t forget to npm init before! ● And npm install express --save for dependencies ● You can add a template engine, add route with parameters, etc
  • 37. Drupal <-> NodeJS Need to install NPM Request module Load it in your Express App Interact with Drupal!