SlideShare a Scribd company logo
A SOA Approximation using Symfony
Joseluis Laso & Carlos Agudo
Who we are
•Carlos Agudo (@karloslupus)
•Joseluis Laso (@jl_laso)
And Others.. (Spanish team)
• Petar Georgiev (@pgkirilov)
• Daniel Abad (@ruudy_es)
• Noel García (@wolfwolker)
• Joaquín Fernández Campo
(@xocas__)
• Miguel Vilata
(@miguelvilata)
Where?
What is Digilant
DSP: Demand Side Platform => programmatic
advertising.
We have a backend to configure ours RTB bidder(s)
architecture.
• A programmatic campaign can have thousands of
parameters.
Long journey
From monolithic sf1 (legacy , 8 years of development)
to a SOA in sf2-3:
Requirements
• API Rest
• Auto Scalable (can be a huge huge demanding
platform)
• Symfony 2
• Easy to deploy
So?
Do not try this at home
Yes Symfony 2-3
Bundle: “A bundle is simply a structured set of files within a
directory that implement a single feature. “
-- We can split services as bundles, and start here.
This sounds weird??
Uncle Bob: “Don't leap into microservices just because it
sounds cool. Segregate the system into jars using a plugin
architecture first. If that's not sufficient, then consider
introducing service boundaries at strategic points.”
Some Questions arose
• One repo? One per service orchestrated with composer?
• One repo, let’s split it later, and coordinate with composer
later. (easier to develop)
• One Db per service? One db for the whole project, with
soft-relations between services?
• One Db for the whole project, let’s split it later. (easier to
develop??, careful with soft-relations, lost of referential
integrity)
Our motto
Let’s split it later
And let’s start!!
Backend Services View
Bundles
Yes, services bundles
Service- Machine
We can create as many services-machine as we want.
Depending on demand. We can cook them!!
Fully elastic scalability.
LineItem Service - Machine
LineItem Core
LineItem- Campaign - Machine
LineItem
Campaign
Core
Cooking Process 1
Using ansistrano (ansible), in each deploy, we can
select how many bundles a machine have.
Machine A- Geo and Creatives Machine B- All services but Pixel
Cooking Process 2
We need to dynamically load, our “bundles-service” on
deploy, our models, our routings, etc..
A lot of magic happens here!
Compiler pass to the rescue!
Cooking Process 3
In our AppKernel.php. We have the LocateBundles (utility
class) in a CoreBundle
Core Bundle
We have a CoreBundle, that act as a glue, (Compiler
passes)
• Communication between services (Can be http-
external, http-internal, process) We have a call
Router. API-REST, that’s why http-internal or external
• Some bussines event listeners (a filter for accounts,
softdelete, audit db listener)
• User-Permission Model
Models 1
In order to don’t get coupled to the persistence
implementation (Doctrine), don’t use annotations for
defining the model, map in an xml:
Models 2
We want to use our own folders:
Base?? We will explain it later, we have an
autogenerator of code.
Models 3
Compiler Pass to Load Models in our own folders.
We pass through our bundles, and
load models, in our folders.
The key:
DoctrineOrmMappingPass
We also use an alias:
LineItem:ThirdPartyData
Geo:City
ServiceName:Model
Others Compilers Passes
Here we load our services
(symfony) in each Bundle.
Also Lists calls (api-rest list
call, defaults limit per
model, orderby etc..)
Others Compilers Passes II
Load the routes per each bundle!
Controller Services
GeoBundle/Resources/config/services.yml
imports:
- resource: ServicesControllers/alpha.yml
We load versionable controllers (alpha, v1..) as services:
Right now: alpha (Remember WIP?)
Routes:
/alpha/creative/*
/current/creative/*
A lot of CRUD tables-controllers
We have a lot of master-
admin tables.
We have a RestController
for this purpose.
Controversy:
- We have a lot of
classes child of this
one.
- Needs refactor in
services!
2nd part
And now ….
The funny part :)
Generator of code
Once upon a time …
We had time and we were youngs :) and we decide to
invest time creating a code generator to make our life
easier … you know ? developers ... this lazy race
With a lot of database schemas per create we thought
that was a good idea to convert this MWB files
directly in code … and was a really nightmare ...
Code generator (AKA mwb-import)
But … it worked
MWB file
it’s a ZIP
xml
sqlite
etc ..
unzip
generate
code with twig
generate
fixtures
Code generator (AKA mwb-import)
ApiDoc documentation generator
document !
document !
document !
document !
document !
document !
ApiDoc documentation generator
But not only generates documentation.
Why don’t use annotations to generate automatic
documentation of API routes ?
There are a couple of bundles in the market that do
this.
Again … we thought that we can do better.
ApiDoc documentation generator
/**
* @ApiDocDescription("Create an Account")
* @ApiDocMethod("post")
* @ApiDocRoute("/account")
* @ApiDocVersion("~")
* @ApiDocSubdomain("account")
* @ApiDocParam(name="maxBudgetValue",type="decimal",nullable=false,description="Account
maxBudgetValue")
* @ApiDocHeader(name="Authorization", placeholder="Authorization: Bearer {token}", type="string",
nullable=false, description="mandatory token obtained in login check call")
* @ApiDocReturnHeader("
* HTTP 200 OK
* Cache-Control: no-cache
* Content-Type: application/json
* ")
* @ApiDocReturnData(type="json", sample="{'id':'integer'}")
*/
public function createAction(Request $request)
Documentator
Features:
automatic creation of documentation in html format,
including a sandbox to test API endpoints
Documentator
Documentator
Features:
automatic creation of documentation in html format,
including a sandbox to test API endpoints
- export to
POSTMAN
collection
Call Router
How to make a call to a service that you even know
where is ?
LineItem Service - Machine
LineItem Core
LineItem- Campaign - Machine
LineItem
Campaign
Core
Call Router
How to call a controller method if you don’t know
where exactly is ?
Remember, we can deploy to n-servers …
To solve that we created a CallRouter that makes the
call internally (if the server has the service required)
or makes the call external (guzzle) if the service is in
another server.
Call Router
try {
// ...
$route = $this->router->match($pathInfo);
return $this->makeInternalCall($route['_controller'], $request);
} catch (ResourceNotFoundException $e) {
return $this->makeExternalCall($request->getMethod(), $subdomain,
$pathInfo, $request->getContent());
}
A soa approximation on symfony
A soa approximation on symfony

More Related Content

Viewers also liked (13)

PDF
Behavioral driven development with Behat
Promet Source
 
PDF
Microservice Teststrategie mit Symfony2
Per Bernhardt
 
PDF
Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...
Alessandro Nadalin
 
PPTX
What mom never told you about bundle configurations - Symfony Live Paris 2012
D
 
PPTX
A SOA approximation on symfony
Joseluis Laso
 
PDF
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Ryan Weaver
 
PDF
Microservice architecture
Xavier Fornés Arrabal
 
PDF
Symfony in microservice architecture
Daniele D'Angeli
 
PDF
High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014
Matthias Noback
 
PPTX
SOA with PHP and Symfony
MichalSchroeder
 
PDF
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Ryan Weaver
 
PDF
Screaming Architecture with Symfony
Bartosz Zasada
 
PPTX
Fracaso renal agudo
jvallejoherrador
 
Behavioral driven development with Behat
Promet Source
 
Microservice Teststrategie mit Symfony2
Per Bernhardt
 
Tips and Tricks for your Service Oriented Architecture @ CakeFest 2013 in San...
Alessandro Nadalin
 
What mom never told you about bundle configurations - Symfony Live Paris 2012
D
 
A SOA approximation on symfony
Joseluis Laso
 
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Ryan Weaver
 
Microservice architecture
Xavier Fornés Arrabal
 
Symfony in microservice architecture
Daniele D'Angeli
 
High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014
Matthias Noback
 
SOA with PHP and Symfony
MichalSchroeder
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Ryan Weaver
 
Screaming Architecture with Symfony
Bartosz Zasada
 
Fracaso renal agudo
jvallejoherrador
 

Similar to A soa approximation on symfony (20)

KEY
The use of Symfony2 @ Overblog
Xavier Hausherr
 
PDF
Symfony2 - from the trenches
Lukas Smith
 
PDF
Symfony2 from the Trenches
Jonathan Wage
 
PDF
The Naked Bundle - Tryout
Matthias Noback
 
PDF
Symfony War Stories
Jakub Zalas
 
PDF
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
PDF
Symfony 4: A new way to develop applications #ipc19
Antonio Peric-Mazar
 
PDF
Scaling PHP apps
Matteo Moretti
 
ODP
An introduction to Symfony 2 for symfony 1 developers
Giorgio Cefaro
 
PDF
Symfony 4: A new way to develop applications #phpsrb
Antonio Peric-Mazar
 
PDF
Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...
Miguel Gallardo
 
PDF
The Naked Bundle - Symfony Usergroup Belgium
Matthias Noback
 
PDF
Symfony 4 Workshop - Limenius
Ignacio Martín
 
PDF
High quality ap is with api platform
Nelson Kopliku
 
PDF
Beyond symfony 1.2 (Symfony Camp 2008)
Fabien Potencier
 
ODP
Learning Symfony2 by practice
Vytautas Beliunas
 
PDF
Scaling symfony apps
Matteo Moretti
 
PDF
The Naked Bundle - Symfony Barcelona
Matthias Noback
 
PDF
Symfony: Your Next Microframework (SymfonyCon 2015)
Ryan Weaver
 
PDF
Modularity problems
Юлия Коваленко
 
The use of Symfony2 @ Overblog
Xavier Hausherr
 
Symfony2 - from the trenches
Lukas Smith
 
Symfony2 from the Trenches
Jonathan Wage
 
The Naked Bundle - Tryout
Matthias Noback
 
Symfony War Stories
Jakub Zalas
 
Building APIs in an easy way using API Platform
Antonio Peric-Mazar
 
Symfony 4: A new way to develop applications #ipc19
Antonio Peric-Mazar
 
Scaling PHP apps
Matteo Moretti
 
An introduction to Symfony 2 for symfony 1 developers
Giorgio Cefaro
 
Symfony 4: A new way to develop applications #phpsrb
Antonio Peric-Mazar
 
Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...
Miguel Gallardo
 
The Naked Bundle - Symfony Usergroup Belgium
Matthias Noback
 
Symfony 4 Workshop - Limenius
Ignacio Martín
 
High quality ap is with api platform
Nelson Kopliku
 
Beyond symfony 1.2 (Symfony Camp 2008)
Fabien Potencier
 
Learning Symfony2 by practice
Vytautas Beliunas
 
Scaling symfony apps
Matteo Moretti
 
The Naked Bundle - Symfony Barcelona
Matthias Noback
 
Symfony: Your Next Microframework (SymfonyCon 2015)
Ryan Weaver
 
Modularity problems
Юлия Коваленко
 
Ad

Recently uploaded (20)

PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Human Resources Information System (HRIS)
Amity University, Patna
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Tally software_Introduction_Presentation
AditiBansal54083
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Ad

A soa approximation on symfony

  • 1. A SOA Approximation using Symfony Joseluis Laso & Carlos Agudo
  • 2. Who we are •Carlos Agudo (@karloslupus) •Joseluis Laso (@jl_laso) And Others.. (Spanish team) • Petar Georgiev (@pgkirilov) • Daniel Abad (@ruudy_es) • Noel García (@wolfwolker) • Joaquín Fernández Campo (@xocas__) • Miguel Vilata (@miguelvilata)
  • 4. What is Digilant DSP: Demand Side Platform => programmatic advertising. We have a backend to configure ours RTB bidder(s) architecture. • A programmatic campaign can have thousands of parameters.
  • 5. Long journey From monolithic sf1 (legacy , 8 years of development) to a SOA in sf2-3:
  • 6. Requirements • API Rest • Auto Scalable (can be a huge huge demanding platform) • Symfony 2 • Easy to deploy
  • 7. So?
  • 8. Do not try this at home
  • 9. Yes Symfony 2-3 Bundle: “A bundle is simply a structured set of files within a directory that implement a single feature. “ -- We can split services as bundles, and start here. This sounds weird?? Uncle Bob: “Don't leap into microservices just because it sounds cool. Segregate the system into jars using a plugin architecture first. If that's not sufficient, then consider introducing service boundaries at strategic points.”
  • 10. Some Questions arose • One repo? One per service orchestrated with composer? • One repo, let’s split it later, and coordinate with composer later. (easier to develop) • One Db per service? One db for the whole project, with soft-relations between services? • One Db for the whole project, let’s split it later. (easier to develop??, careful with soft-relations, lost of referential integrity)
  • 11. Our motto Let’s split it later And let’s start!!
  • 14. Service- Machine We can create as many services-machine as we want. Depending on demand. We can cook them!! Fully elastic scalability. LineItem Service - Machine LineItem Core LineItem- Campaign - Machine LineItem Campaign Core
  • 15. Cooking Process 1 Using ansistrano (ansible), in each deploy, we can select how many bundles a machine have. Machine A- Geo and Creatives Machine B- All services but Pixel
  • 16. Cooking Process 2 We need to dynamically load, our “bundles-service” on deploy, our models, our routings, etc.. A lot of magic happens here! Compiler pass to the rescue!
  • 17. Cooking Process 3 In our AppKernel.php. We have the LocateBundles (utility class) in a CoreBundle
  • 18. Core Bundle We have a CoreBundle, that act as a glue, (Compiler passes) • Communication between services (Can be http- external, http-internal, process) We have a call Router. API-REST, that’s why http-internal or external • Some bussines event listeners (a filter for accounts, softdelete, audit db listener) • User-Permission Model
  • 19. Models 1 In order to don’t get coupled to the persistence implementation (Doctrine), don’t use annotations for defining the model, map in an xml:
  • 20. Models 2 We want to use our own folders: Base?? We will explain it later, we have an autogenerator of code.
  • 21. Models 3 Compiler Pass to Load Models in our own folders. We pass through our bundles, and load models, in our folders. The key: DoctrineOrmMappingPass We also use an alias: LineItem:ThirdPartyData Geo:City ServiceName:Model
  • 22. Others Compilers Passes Here we load our services (symfony) in each Bundle. Also Lists calls (api-rest list call, defaults limit per model, orderby etc..)
  • 23. Others Compilers Passes II Load the routes per each bundle!
  • 24. Controller Services GeoBundle/Resources/config/services.yml imports: - resource: ServicesControllers/alpha.yml We load versionable controllers (alpha, v1..) as services: Right now: alpha (Remember WIP?) Routes: /alpha/creative/* /current/creative/*
  • 25. A lot of CRUD tables-controllers We have a lot of master- admin tables. We have a RestController for this purpose. Controversy: - We have a lot of classes child of this one. - Needs refactor in services!
  • 26. 2nd part And now …. The funny part :)
  • 27. Generator of code Once upon a time … We had time and we were youngs :) and we decide to invest time creating a code generator to make our life easier … you know ? developers ... this lazy race With a lot of database schemas per create we thought that was a good idea to convert this MWB files directly in code … and was a really nightmare ...
  • 28. Code generator (AKA mwb-import) But … it worked MWB file it’s a ZIP xml sqlite etc .. unzip generate code with twig generate fixtures
  • 29. Code generator (AKA mwb-import)
  • 30. ApiDoc documentation generator document ! document ! document ! document ! document ! document !
  • 31. ApiDoc documentation generator But not only generates documentation. Why don’t use annotations to generate automatic documentation of API routes ? There are a couple of bundles in the market that do this. Again … we thought that we can do better.
  • 32. ApiDoc documentation generator /** * @ApiDocDescription("Create an Account") * @ApiDocMethod("post") * @ApiDocRoute("/account") * @ApiDocVersion("~") * @ApiDocSubdomain("account") * @ApiDocParam(name="maxBudgetValue",type="decimal",nullable=false,description="Account maxBudgetValue") * @ApiDocHeader(name="Authorization", placeholder="Authorization: Bearer {token}", type="string", nullable=false, description="mandatory token obtained in login check call") * @ApiDocReturnHeader(" * HTTP 200 OK * Cache-Control: no-cache * Content-Type: application/json * ") * @ApiDocReturnData(type="json", sample="{'id':'integer'}") */ public function createAction(Request $request)
  • 33. Documentator Features: automatic creation of documentation in html format, including a sandbox to test API endpoints
  • 35. Documentator Features: automatic creation of documentation in html format, including a sandbox to test API endpoints - export to POSTMAN collection
  • 36. Call Router How to make a call to a service that you even know where is ? LineItem Service - Machine LineItem Core LineItem- Campaign - Machine LineItem Campaign Core
  • 37. Call Router How to call a controller method if you don’t know where exactly is ? Remember, we can deploy to n-servers … To solve that we created a CallRouter that makes the call internally (if the server has the service required) or makes the call external (guzzle) if the service is in another server.
  • 38. Call Router try { // ... $route = $this->router->match($pathInfo); return $this->makeInternalCall($route['_controller'], $request); } catch (ResourceNotFoundException $e) { return $this->makeExternalCall($request->getMethod(), $subdomain, $pathInfo, $request->getContent()); }