SlideShare a Scribd company logo
How I built web services in CakePHP
Amsterdam
2016
Introduction
PHP Developer
at UK Web Media
in Weyhill, UK
http://www.ukwm.co.uk
Cyberstalk me!
https://twitter.com/YellDavid
https://github.com/davidyell
http://careers.stackoverflow.com/davidyell
http://uk.linkedin.com/in/davidyell
#cakephp on Freenode IRC
David Yell
aka Neon1024
Agenda
System architecture
Version 1
Version 2
Version 3
CakePHP 2
CakePHP 2
CakePHP 3
System architecture
CMS
Web
Service
Client websites
The
Internet
ApiUpdatable
Driver
Plugins
Read-only
Queue
Setup
/api/v1
Api
ApiAuth
Yey!
● Plugin architecture
● Self-contained
Boo!
● Single fat controller
● Lack of separation
● Less flexible
Routing
Request
Response
Plugins
Version 1
v1 prefix
The Fat Controller
Version 1
Api Plugin
/api/v1
● Hard to maintain
● Lack of flexibility
● Not DRY
● No separation of
concerns
● Custom views
Version 1
ApiAuth Plugin
/api/v1
● No standards
● Open GET params
● No security
Version 1
Setup
/api/v2
Yey!
●
Shares existing code
●
More generic
● Extensibility
● Per endpoint customisation
Boo!
●
Hard to create common filtering
● Too much code in AppController
●
Lacks separation
Routing
Request
Response
Application
Version 2
v2 prefix
AppController ProductsController
API Design choices
Pragmatic approach
Complex queries but more complete responses
Allows complete configured return
Flexible filtering and sorting
Specific use-cases
Further reading,
http://www.bravo-kernel.com/tags/api/
Version 3
Routing
Request
Response
api prefix
v3 route
ApiAppController
Crud plugin
Custom Crud actions
Contain class Filter class
Yey!
● Crud automation
● Free sorting and pagination
● Code separation
● Extensible
Boo!
● Complexity
Setup
/api/v3
ApiQuery Behavior
Version with prefixes
src/Controller/Api/V3/PackagesController.php
src/Controller/Api/V4/PackagesController.php
/api/v3/packages.json
/api/v4/packages.json
Crud plugin
friendsofcake/crud
Event driven scaffolding
Be lazy
Do less work
??
Profit
http://www.bravo-kernel.com/2015/04/how-to-build-a-cakephp-3-
rest-api-in-minutes/
Crud Index Action
Crud Index Action
Related data
Contain all the things
Version 3
Version 3
Filtering data
Match all the things
Version 3
Example queries
Get packages with related data, where line rental is included,
from provider id 4, matching an associated Table field, sorted
by price, on page 2.
/api/v3/packages.json
?verbose=true
&filter[line_rental_included]=true
&filter[provider_id]=4
&filter[Related.something]=foo
&site_id=n
&limit=20
&page=3
&sort=price
&direction=asc
Free with Crud plugin!
Version 3
Example queries
Get a specific list of packages in a certain order.
/api/v3/packages.json
?id[0]=19
&id[1]=17
&id[2]=11
&id[3]=43
&site_id=n
Lessons learned
Don't
● Single controller
● Filter in controller
Do
● Routing prefixes
● Crud plugin
● Authentication
● Create separation
● Integration testing
Toolset
friendsofcake/crud
friendsofcake/search
admad/cakephp-jwt-auth
muffin/webservice
league/fractal
https://www.getpostman.com/
Consuming the API
Cake 2
Custom data source
http://book.cakephp.org/2.0/en/models/datasources.html
Muffin/WebService Cake 3 driver
http://jedistirfry.co.uk/blog/2015-09/connecting-to-a-web-service/
Consuming the API
Cake 3
Thanks!
Questions?
Please rate my talk
https://joind.in/talk/e2065
Attend your local PHP Usergroup! http://php.ug/
http://osmihelp.org/donate

More Related Content

What's hot

MJML API @ Paris API
MJML API  @ Paris APIMJML API  @ Paris API
MJML API @ Paris API
Julien Ernewein
 
Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.
WordCamp Harare
 
Building End to-End Web Apps Using TypeScript
Building End to-End Web Apps Using TypeScriptBuilding End to-End Web Apps Using TypeScript
Building End to-End Web Apps Using TypeScript
Gil Fink
 
Web development meetingup
Web development meetingupWeb development meetingup
Web development meetingupPiTechnologies
 
Vaadin slides for @Devoxx 2012
Vaadin slides for @Devoxx 2012Vaadin slides for @Devoxx 2012
Vaadin slides for @Devoxx 2012
Nicolas Fränkel
 
Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015
AboutYouGmbH
 
Git in 10 minutes (WordCamp Europe 2017)
Git in 10 minutes (WordCamp Europe 2017)Git in 10 minutes (WordCamp Europe 2017)
Git in 10 minutes (WordCamp Europe 2017)
Borek Bernard
 
Creating real time applications with Angular and Firebase
Creating real time applications with Angular and FirebaseCreating real time applications with Angular and Firebase
Creating real time applications with Angular and Firebase
Loiane Groner
 
180929_NextBuild_From_Java_to_Kotlin
180929_NextBuild_From_Java_to_Kotlin180929_NextBuild_From_Java_to_Kotlin
180929_NextBuild_From_Java_to_Kotlin
Paulien van Alst
 
Plugin for CakePHP2.0
Plugin for CakePHP2.0Plugin for CakePHP2.0
Plugin for CakePHP2.0
Takashi Nojima
 
Untangle Your Front End Development with Visual Studio 2015
Untangle Your Front End Development with Visual Studio 2015Untangle Your Front End Development with Visual Studio 2015
Untangle Your Front End Development with Visual Studio 2015
Scott Heckel
 
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Dat Hoang
 
PWA - Progressive Web App
PWA - Progressive Web AppPWA - Progressive Web App
PWA - Progressive Web App
Laravel Poland MeetUp
 
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetupWordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
rtCamp
 
That worked before
That worked beforeThat worked before
That worked before
Christian Güdemann
 
Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...
Alexandra N. Martinez
 
To The Word And Beyond! Extending WordPress Past a Simple Blog
To The Word And Beyond! Extending WordPress Past a Simple BlogTo The Word And Beyond! Extending WordPress Past a Simple Blog
To The Word And Beyond! Extending WordPress Past a Simple Blog
Meagan Hanes
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Diego Pacheco
 

What's hot (20)

MJML API @ Paris API
MJML API  @ Paris APIMJML API  @ Paris API
MJML API @ Paris API
 
Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.
 
Building End to-End Web Apps Using TypeScript
Building End to-End Web Apps Using TypeScriptBuilding End to-End Web Apps Using TypeScript
Building End to-End Web Apps Using TypeScript
 
Web development meetingup
Web development meetingupWeb development meetingup
Web development meetingup
 
Vaadin slides for @Devoxx 2012
Vaadin slides for @Devoxx 2012Vaadin slides for @Devoxx 2012
Vaadin slides for @Devoxx 2012
 
Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015Robin Böhm - Angular 2 - code.talks 2015
Robin Böhm - Angular 2 - code.talks 2015
 
Git in 10 minutes (WordCamp Europe 2017)
Git in 10 minutes (WordCamp Europe 2017)Git in 10 minutes (WordCamp Europe 2017)
Git in 10 minutes (WordCamp Europe 2017)
 
Creating real time applications with Angular and Firebase
Creating real time applications with Angular and FirebaseCreating real time applications with Angular and Firebase
Creating real time applications with Angular and Firebase
 
180929_NextBuild_From_Java_to_Kotlin
180929_NextBuild_From_Java_to_Kotlin180929_NextBuild_From_Java_to_Kotlin
180929_NextBuild_From_Java_to_Kotlin
 
Plugin for CakePHP2.0
Plugin for CakePHP2.0Plugin for CakePHP2.0
Plugin for CakePHP2.0
 
Untangle Your Front End Development with Visual Studio 2015
Untangle Your Front End Development with Visual Studio 2015Untangle Your Front End Development with Visual Studio 2015
Untangle Your Front End Development with Visual Studio 2015
 
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
 
MVA-Transcript
MVA-TranscriptMVA-Transcript
MVA-Transcript
 
PWA - Progressive Web App
PWA - Progressive Web AppPWA - Progressive Web App
PWA - Progressive Web App
 
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetupWordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
 
That worked before
That worked beforeThat worked before
That worked before
 
Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...Women Who Mule - Workshop series: Create your own blog from scratch without a...
Women Who Mule - Workshop series: Create your own blog from scratch without a...
 
To The Word And Beyond! Extending WordPress Past a Simple Blog
To The Word And Beyond! Extending WordPress Past a Simple BlogTo The Word And Beyond! Extending WordPress Past a Simple Blog
To The Word And Beyond! Extending WordPress Past a Simple Blog
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
EVOLVE'13 | Keynote | Richard Brown
EVOLVE'13 | Keynote | Richard BrownEVOLVE'13 | Keynote | Richard Brown
EVOLVE'13 | Keynote | Richard Brown
 

Similar to How I built web services in CakePHP

Make web as webapp
Make web as webappMake web as webapp
Make web as webapp
Fred Lin
 
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
David Yell
 
PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3
David Yell
 
GoPro, Inc. Case study: Dive into the details of our web applications
GoPro, Inc. Case study: Dive into the details of our web applicationsGoPro, Inc. Case study: Dive into the details of our web applications
GoPro, Inc. Case study: Dive into the details of our web applications
Andrew Maxwell
 
Joomlatools Platform v2.0
Joomlatools Platform v2.0Joomlatools Platform v2.0
Joomlatools Platform v2.0
Joomlatools
 
Pro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii Ivashchenko
Pro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii IvashchenkoPro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii Ivashchenko
Pro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii Ivashchenko
Pro Magento Community
 
Go Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applicationsGo Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applications
Andrew Maxwell
 
Webplatform And Php
Webplatform And PhpWebplatform And Php
Webplatform And Php
Pierre Joye
 
Introducing ASP.NET vNext - A tour of the new ASP.NET platform
Introducing ASP.NET vNext - A tour of the new ASP.NET platformIntroducing ASP.NET vNext - A tour of the new ASP.NET platform
Introducing ASP.NET vNext - A tour of the new ASP.NET platform
Jeffrey T. Fritz
 
Modular Web Applications based on OSGi - Jochen Hiller
Modular Web Applications based on OSGi - Jochen HillerModular Web Applications based on OSGi - Jochen Hiller
Modular Web Applications based on OSGi - Jochen Hiller
mfrancis
 
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
Enea Gabriel
 
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
FalafelSoftware
 
Making sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developersMaking sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developers
Lewiz
 
Joomlatools Platform v1.0
Joomlatools Platform v1.0Joomlatools Platform v1.0
Joomlatools Platform v1.0
Joomlatools
 
Php Performance On Windows
Php Performance On WindowsPhp Performance On Windows
Php Performance On Windows
ruslany
 
Rev it up with php on windows
Rev it up with php on windowsRev it up with php on windows
Rev it up with php on windows
Josh Holmes
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testing
Engineor
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
Engineor
 
Web componenet using angular element
Web componenet using angular elementWeb componenet using angular element
Web componenet using angular element
Himanshu Tamrakar
 
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
Antonio Peña
 

Similar to How I built web services in CakePHP (20)

Make web as webapp
Make web as webappMake web as webapp
Make web as webapp
 
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
 
PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3
 
GoPro, Inc. Case study: Dive into the details of our web applications
GoPro, Inc. Case study: Dive into the details of our web applicationsGoPro, Inc. Case study: Dive into the details of our web applications
GoPro, Inc. Case study: Dive into the details of our web applications
 
Joomlatools Platform v2.0
Joomlatools Platform v2.0Joomlatools Platform v2.0
Joomlatools Platform v2.0
 
Pro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii Ivashchenko
Pro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii IvashchenkoPro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii Ivashchenko
Pro Magento MeetUp #4 - Upgrade Compatibility Tool, Sergii Ivashchenko
 
Go Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applicationsGo Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applications
 
Webplatform And Php
Webplatform And PhpWebplatform And Php
Webplatform And Php
 
Introducing ASP.NET vNext - A tour of the new ASP.NET platform
Introducing ASP.NET vNext - A tour of the new ASP.NET platformIntroducing ASP.NET vNext - A tour of the new ASP.NET platform
Introducing ASP.NET vNext - A tour of the new ASP.NET platform
 
Modular Web Applications based on OSGi - Jochen Hiller
Modular Web Applications based on OSGi - Jochen HillerModular Web Applications based on OSGi - Jochen Hiller
Modular Web Applications based on OSGi - Jochen Hiller
 
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
 
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
Introducing ASP.NET vNext – The Future of .NET on the Server | FalafelCON 2014
 
Making sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developersMaking sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developers
 
Joomlatools Platform v1.0
Joomlatools Platform v1.0Joomlatools Platform v1.0
Joomlatools Platform v1.0
 
Php Performance On Windows
Php Performance On WindowsPhp Performance On Windows
Php Performance On Windows
 
Rev it up with php on windows
Rev it up with php on windowsRev it up with php on windows
Rev it up with php on windows
 
Codeception: introduction to php testing
Codeception: introduction to php testingCodeception: introduction to php testing
Codeception: introduction to php testing
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
 
Web componenet using angular element
Web componenet using angular elementWeb componenet using angular element
Web componenet using angular element
 
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
 

Recently uploaded

Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 

Recently uploaded (20)

Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 

How I built web services in CakePHP

Editor's Notes

  1. Thanks for voting on my talk, I really appreciate it. Nearly 10 years commercial experience, mostly agencies doing campaign work. Started with HTML on GeoCities. Self-taught in PHP, started with CakePHP on 1.3 in 2008 ish and am in the Friends of Cake group UKWM do campaign and affiliate marketing work, I work mostly on the telecoms sites comparing broadband, tv and phone All our stuff is CakePHP 2 or 3, I'm migrating stuff as and when I have time This is the first run of this presentation so be gentle! I will hopefully have some time at the end for questions.
  2. It's what I do for my job v1 is the first api I ever built! It's a read only web service Built by myself, used by myself Work in progress We are silo'd at work, so you guys are doing my code review for me!
  3. The web service driver is a Datasource in Cake 2, and a web service driver in Cake 3. The use-case is a centrally managed data-store ApiUpdatable has a queue to schedule updates from the client site It also has a shell run on a cron Thin clients pull data from the web service on render and use local cache Multiple versions of the API with clients being migrated over
  4. First ever api I built A plugin seemed logical at the time Coded first rather than designing it Difficult containing deep associations, 4-5 levels Ended up filtering data in the view, so the pagination meta was wrong Index method in ApiController is 247 lines long!
  5. If your controller looks like this, stop, and rethink
  6. Not flexible enough to expand to cover new use-cases easily Plugin needs tagging and releasing Duplicating functionality which already exists in the application Manual work to create the views
  7. Who knows what past me was thinking with this one. Even the templates are in the other plugin!
  8. All base endpoint methods are in the AppController Overload the methods as needed Extended methods means filtering would be complex on a per endpoint basis Never even made it out of the branch!
  9. Reqs: Allows for complex sorting and filtering combinations Makes my client implementation simple Full comparison table data Pragmatic approach, practice rather than theory Fulfils use-cases of complex full data returns Not using the RESTful routing Hidden the _matchingData Focus on simplicity for the client The utopian vision of everything being achievable
  10. Controller inheritance Crud plugin makes it easy Custom actions to call behavour methods on the query Behaviour uses custom finders to modify query Uses the ORMs stackable finders feature Doesn't adhere to REST standard, pragmatic and solo! ;) Filter and contain classes implement an interface, and customised per endpoint As Jose said in the workshop, don't be scared to go outside the framework Related data class also deals with sortable whitelist Luckily I have only 5 endpoints, 2 primary ones
  11. Neat code separation Can still inherit from ApiController Easy to run multiple versions from the same app
  12. Can help you build a basic api in literally minutes! Comes with pagination and sorting out of the box Has various api listeners, Api ApiPaginator ApiQueryLog Search listener implements the friendsofcake/search plugin Not as complicated as it appears, I'm working on the docs, so any contributions welcome!
  13. Copy and paste of the default crud action Just added some extra methods to hook into the query object The methods just look for the behaviour and call it's custom finders on the query
  14. Example Crud index action method _table is the current table, proxied call to Controller::loadModel() in Crud core Just passing a Cake\ORM\Query object Awesome because it's lazy I can build the query programatically and execute it later
  15. Relies on awesome Cake 3 ORM with closures in my contains to filter my associations Highly customisable Boss asked to remove pricing, comment out the line, job done, 2 mins – comment because I know he'll change his mind ;) Low impact, as it's tied to a single endpoint Lots of code though, so can look daunting Manages both Joins and Contains, as some fields must be joined for filtering and sorting Lives in src/Lib/Api/RelatedData
  16. Build filters as an array in the url I can pass all the filters around by just passing the array Allow for highly complex filtering Flexible and easy for clients to understand Has custom field filters too such as minPrice and maxPrice which map to the price field Lives in src/Lib/Api/Filters
  17. Might not want to expose your schema Could use a custom JSON view or use Fractal Can return a complete response for the client implementation
  18. For affiliate marketing comparison tables we need things in an arbitrary order set in the client site CMS Again, - Might not want to expose your schema - Could use a custom JSON view or use Fractal
  19. Routing prefixes good for versioning, as they can be nested! So why not an api prefix, with a v2 prefix and v3 prefix? Don't be constrained by the framework where it doesn't make sense. Not all of your code needs to fit into the framework, but check first! Theoretical paralysis, too much thinking not enough doing. Be pragmatic. Create a branch, try a thing, ditch it and start over. Three branches before sorting worked! Testing using json fixture files
  20. Postman client for testing your endpoints yourself
  21. Cake 2 ApiUpdatable behaviour swaps the datasource based on if the query has the ‘api’ => true option set in the find conditions using a callback Data returned as json array
  22. Service info configured in your app.php under Webservices config key Will return json entities directly from a cake 3 endpoint
  23. If you'd like to discuss anything in my talk, please come see me for a chat.