SlideShare a Scribd company logo
Case study: eZ Publish
Symfony2 http kernel for legacy apps
Gaetano Giunta | PUG Milano | Maggio 2013
The drivers
 Existing codebase is 10 years old 
 High maintenance cost
 Started with no unit tests
 Layers and roles not properly defined / documented
 OOP before php had
 Private/protected/static
 Closures
 Namespaces
 Late static binding
 And much more
 Not built for an Ajax and REST world
5/18/2013gg@ez.no Slide 3
Why change?
Everyone loves NEW!
 Existing codebase is 10 years old 
 Widely deployed
 Well debugged
 Pitfalls have probably been uncovered by now
 Proven to scale
 Well known:
 Documentation improved over years
 Tutorials, forums, blogs, aggregators
 Active community of practitioners
 Official training courses
5/18/2013gg@ez.no Slide 4
Why change?
Do not forget drawbacks
 Focus on our core business
 Experience Management
 Content Management
 NOT Framework maintenance
 DurableArchitecture
 API stability
 Battle tested / not (only) the latest trend
 Scalability
 Lively Community!
5/18/2013gg@ez.no Slide 5
Picking a framework for a platform rebuild
• Simple Integration with existing API
• HMVC (Hierarchical Model View Controller) stack
• Decoupled Components
• Dependency Injection
• Good Template Engine
• Extensible, Open, Reliable ;-)
5/18/2013gg@ez.no Slide 6
Prerequisites
• Home brew
• Zeta Components
• Zend Framework 2
• Symfony 2 (Full Stack!)
5/18/2013gg@ez.no Slide 7
Candidates
5/18/2013gg@ez.no Slide 8
And the winner is…
Title of presentation is a hint, really...
The challenge
Product Management SCRUM Story:
«As an existing user, I don’t want to be pissed off by a new #@!$% version!»
5/18/2013gg@ez.no Slide 10
Backwards compatibility
(life sucks)
Product Management SCRUM Story:
«As an existing user, I don’t want to be pissed off by a new #@!$% version!»
• 100% Data Compatible (same DB scheme)
• Possibility to include legacy templates in the new ones
• Routing fallback
• Load legacy content templates with legacy rules
• Settings
• Access Symfony services from legacy modules
5/18/2013gg@ez.no Slide 11
Backwards compatibility: the objectives
Product Management SCRUM Story:
«As an existing user, I don’t want to be pissed off by a new #@!$% version!»
• 100% Data Compatible (same DB scheme)
• Possibility to include legacy templates in the new ones
• Routing fallback
• Load legacy content templates with legacy rules
• Settings
• Access Symfony services from legacy modules
5/18/2013gg@ez.no Slide 12
Backwards compatibility: the objectives
A new architecture
Product Management SCRUM Story:
«As an existing user, I don’t want to be pissed off by a new #@!$% version!»
• 100% Data Compatible (same DB scheme)
• Possibility to include legacy templates in the new ones
• Routing fallback
• Load legacy content templates with legacy rules
• Settings
• Access Symfony services from legacy modules
Challenge Accepted
5/18/2013gg@ez.no Slide 14
BC: the challenge
5/18/2013gg@ez.no Slide 15
Dual-core architecture
Legacy version still works perfectly standalone
5/18/2013gg@ez.no Slide 16
BC: icing on the cake
Isn’t this what you have been waiting for?
The HTTP Kernel
Request => process() => Response
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
$request = Request::createFromGlobals();
$input = $request->get('name', 'World'); // allows a default value
$response = new Response('Hello ' . htmlspecialchars($input, ENT_QUOTES, 'UTF-8'));
$response->send(); // takes care of http headers
 The HTTPFoundation Component eases mundane tasks
5/18/2013gg@ez.no Slide 18
Use the HTTP, Luke
A very, very simple frontend controller
 The HTTPKernel component “formalizes the process of starting with a request
and creating the appropriate response”
interface HttpKernelInterface
{
const MASTER_REQUEST = 1;
const SUB_REQUEST = 2;
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true);
}
 Returns a Response instance
 The «H» in HMVC: subrequests are baked in from the beginning
 Looks simple so far, isn’t it?
5/18/2013gg@ez.no Slide 19
The heart of the application
 The HttpKernel defines a complex flexible workflow
 The controller to execute is found via a ControllerResolver
 «Framework» work is done via an event system / event listeners
5/18/2013gg@ez.no Slide 20
Adding the magic
$request = Request::createFromGlobals();
$dispatcher = new EventDispatcher();
// ... add some event listeners, eg: routing, security checking
// create the controller resolver
$resolver = new MyControllerResolver();
// instantiate the kernel
$kernel = new HttpKernel( $dispatcher, $resolver );
$response = $kernel->handle( $request );
$response->send();
$kernel->terminate( $request, $response );
5/18/2013gg@ez.no Slide 21
Building a frontend controller
 Any class implementing the ControllerResolverInterface can be used
interface ControllerResolverInterface
{
// must return a callable
public function getController(Request $request);
// returns an array of arguments for the controller
public function getArguments(Request $request, $controller);
}
 ...
5/18/2013gg@ez.no Slide 22
Finding the Controller
 The Event Dispatcher Component can be used
use SymfonyComponentEventDispatcherEvent;
$dispatcher->addListener('foo.action', $callable);
 Depending on returned value, workflow might be altered (see docs online)
 Dispatchedevents:
Name Name as constant Argument passed to the listener
kernel.request KernelEvents::REQUEST GetResponseEvent
kernel.controller KernelEvents::CONTROLLER FilterControllerEvent
kernel.view KernelEvents::VIEW GetResponseForControllerResultEvent
kernel.response KernelEvents::RESPONSE FilterResponseEvent
kernel.terminate KernelEvents::TERMINATE PostResponseEvent
kernel.exception KernelEvents::EXCEPTION GetResponseForExceptionEvent
5/18/2013gg@ez.no Slide 23
Adding event listeners
Taming the beast
 New Core: a standard Simfony app («ezpublish» = «app»)
 «Legacy Stack» isolated in a dedicated directory
5/18/2013gg@ez.no Slide 25
Refactoring: directory layout
 New Core: Sf Bundles
5/18/2013gg@ez.no Slide 26
Refactoring: bundles
use SymfonyComponentHttpFoundationRequest;
require_once __DIR__ . '/../ezpublish/autoload.php'; // set up class autoloading
require_once __DIR__ . '/../ezpublish/EzPublishKernel.php';
$kernel = new EzPublishKernel( 'dev', true ); // extends the Sf Kernel class
$kernel->loadClassCache(); // a method from parent class
$request = Request::createFromGlobals();
$response = $kernel->handle( $request );
$response->send();
$kernel->terminate( $request, $response );
 The Kernel class wraps the HTTPKernel
 It adds a Service Container
 It allows to register bundles via registerBundles()
5/18/2013gg@ez.no Slide 27
The final frontend controller
Using Symfony Full Stack
 Sandbox legacy code in a closure
 Index.php had to be refactored (from 1100 lines to 20)
 Logic moved to a php class
 Separated environment setup from execution and teardown
 runCallback() sets up the global legacy environment
5/18/2013gg@ez.no Slide 28
Refactoring: bridging Legacy code
Routing
 eZPublish 4 uses a custom MVC implementation
 Frontend controller: index.php
 Bootstraps configuration system, logging, “siteaccess”
 Controllers are “plain php” files, properly declared
 Url syntax: http:// site / module / controller / parameters
 Parameters use a custom format instead of the query string
 Virtual aliases can be added on top
 For all content nodes, a nice alias is always generated by the system
 Good for SEO
Technical debt
 No DIC anywhere (registry pattern used)
 No nested controllers
 No provision for REST / AJAX
 Implemented ad-hoc in many plugins (code/functionality duplication)
 Policies are tied to controllers, not to the underlying content model
5/18/2013gg@ez.no Slide 30
Routing
5/18/2013gg@ez.no Slide 31
Routing: seamless integration
 The ChainRouter from the Sf CMF project is used
 Routes for new controllers can be declared in different ways
 In a configuration file
 app/config/routing.yml
 Mybundle/Resources/config/routing.yml (loaded from main routing file)
 Via annotations (phpdoc comments)
 needs the SensioFrameworkExtraBundle bundle
 Command line to dump them
php app/console router:debug
 Maximum flexibility for parameters: required/optionsl, default values,
validation, restrict http method, extra support for locale and format, ...
5/18/2013gg@ez.no Slide 32
Routing: how it works
Caching
 eZ Publish 4 has a complicated advanced caching system
 For viewing content, cache is generated on access, invalidated on editing
 TTL = infinite
 When editing a content, cache is also invalidated for all related contents
 Extra invalidation rules can be configured
 Can be set up to be pregenerated at editing time (tradeoff: editing speed)
 Cache keys include policies of current user, query string, custom session data
 “Cache-blocks” can also be added anywhere in the templates
 Expiry rules can be set on each block, TTL-based or content-editing based
 Breaks mvc principle
 Most powerful AND misunderstoodfeature in the CMS
5/18/2013gg@ez.no Slide 34
eZ4 Caching: basics
 eZ has a built-in “full-page cache” (stores html on disk)
 Currently deprecated, in favour of using a caching reverse Proxy
 Performances same if not better
 Delegate maintenance of part of the stack (Varnish, Squid)
 Holy grail of caching: high TTL and support for PURGE command
1. When RP requests page from server, he gets a high TTL => cache page forever
2. When page changes, server tells to RP to purge that url from cache
 Best reduction in number of requests to server while always showing fresh data
 Downside: extremely hard to cache pages for connected users
 ESI support as well
 Hard to make efficient, as eZ can not regenerate an ESI block without full page
context
5/18/2013gg@ez.no Slide 35
eZ4 Caching: integration with Reverse Proxies
 HTTP Expiration and Validation are used
 By setting caching headers on response object
 Integrates with a Gateway Cache (a.k.a Reverse Proxy)
 Native (built-in, php)
$kernel = new Kernel('prod', false);
$kernel = new HTTPCache($kernel);
 External (Varnish, Squid, ...)
 Native support for ESI
 Using {{ render_esi() }} in twig
5/18/2013gg@ez.no Slide 36
Symfony Caching: basics
REST
 eZ4 had an incomplete REST API
 Only functionality available: reading content
 Based on Zeta Components MVC component
 A new API has been implemented
 Full reading and writing of content is possible
 All “dictionary” data is also available
 Content-type for response can be JSON or XML (with an XSD!)
 Fully restful
 Usage of all HTTP verbs (and then some: PATCH)
 Respect http headers of request (eg: “Accept”)
 HATEOAS: use urls as resource ids
 No separate request handling framework needed: pure Symfony routing
 Bonus points: a client for the REST API, implements the same interfaces exposed
by the local PHP API – network transparency!!!
5/18/2013gg@ez.no Slide 40
REST API
More info
 Tutorials:
 http://fabien.potencier.org/article/50/create-your-own-framework-on-top-of-the-
symfony2-components-part-1
 http://symfony.com/doc/current/components/http_kernel/introduction.html
 Sf2 book – jolly good looking docs:
http://symfony.com/doc/current/book/index.html
 eZ Publish:
 Community: http://share.ez.no
 Source code: https://github.com/ezsystems
 API docs: http://pubsvn.ez.no/preview.html
 Contact me: @gggeek, gaetano.giunta@ez.no
5/18/2013gg@ez.no Slide 42
The usual suspects

More Related Content

What's hot

Tomcat server
 Tomcat server Tomcat server
Tomcat server
Utkarsh Agarwal
 
Changes in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowChanges in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must Know
Bruno Borges
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
ejlp12
 
Virtual CD4PE Workshop
Virtual CD4PE WorkshopVirtual CD4PE Workshop
Virtual CD4PE Workshop
Puppet
 
Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 Presentation
Tomcat Expert
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna
 
Tribal Nova Docker feedback
Tribal Nova Docker feedbackTribal Nova Docker feedback
Tribal Nova Docker feedback
Nicolas Degardin
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
Hsi-Kai Wang
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
WebStackAcademy
 
Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)
Mathew Beane
 
Jetty Vs Tomcat
Jetty Vs TomcatJetty Vs Tomcat
Jetty Vs Tomcat
Tomoaki Sawada
 
Tomcat Clustering
Tomcat ClusteringTomcat Clustering
Tomcat Clustering
gouthamrv
 
Apache tomcat
Apache tomcatApache tomcat
Apache tomcat
Shashwat Shriparv
 
Tomcat
TomcatTomcat
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDevTriple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
Werner Keil
 
플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포
흥래 김
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
Jackson F. de A. Mafra
 
Tales from the OSGi trenches
Tales from the OSGi trenchesTales from the OSGi trenches
Tales from the OSGi trenches
Bertrand Delacretaz
 
Managing an OSGi Framework with Apache Felix Web Console
Managing an OSGi Framework with  Apache Felix Web ConsoleManaging an OSGi Framework with  Apache Felix Web Console
Managing an OSGi Framework with Apache Felix Web Console
Felix Meschberger
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
Ryan Cuprak
 

What's hot (20)

Tomcat server
 Tomcat server Tomcat server
Tomcat server
 
Changes in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must KnowChanges in WebLogic 12.1.3 Every Administrator Must Know
Changes in WebLogic 12.1.3 Every Administrator Must Know
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 
Virtual CD4PE Workshop
Virtual CD4PE WorkshopVirtual CD4PE Workshop
Virtual CD4PE Workshop
 
Introduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 PresentationIntroduction to Apache Tomcat 7 Presentation
Introduction to Apache Tomcat 7 Presentation
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Tribal Nova Docker feedback
Tribal Nova Docker feedbackTribal Nova Docker feedback
Tribal Nova Docker feedback
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 
Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)Z-Ray: A customizable development tool belt (Zendcon 2016)
Z-Ray: A customizable development tool belt (Zendcon 2016)
 
Jetty Vs Tomcat
Jetty Vs TomcatJetty Vs Tomcat
Jetty Vs Tomcat
 
Tomcat Clustering
Tomcat ClusteringTomcat Clustering
Tomcat Clustering
 
Apache tomcat
Apache tomcatApache tomcat
Apache tomcat
 
Tomcat
TomcatTomcat
Tomcat
 
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDevTriple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
Triple E class DevOps with Hudson, Maven, Kokki/Multiconf and PyDev
 
플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포플랫폼 통합을 위한 Client Module 개발 & 배포
플랫폼 통합을 위한 Client Module 개발 & 배포
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
Tales from the OSGi trenches
Tales from the OSGi trenchesTales from the OSGi trenches
Tales from the OSGi trenches
 
Managing an OSGi Framework with Apache Felix Web Console
Managing an OSGi Framework with  Apache Felix Web ConsoleManaging an OSGi Framework with  Apache Felix Web Console
Managing an OSGi Framework with Apache Felix Web Console
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 

Similar to Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - Pug Milano 2013

eZPublish meets Simfony2 - phpDay2013
eZPublish meets Simfony2  - phpDay2013eZPublish meets Simfony2  - phpDay2013
eZPublish meets Simfony2 - phpDay2013
Gaetano Giunta
 
Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHP
Edureka!
 
Building Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHPBuilding Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHP
Edureka!
 
Play Framework
Play FrameworkPlay Framework
Play Framework
Harinath Krishnamoorthy
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
Frankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiFrankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGi
Toni Epple
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best Practices
Burt Beckwith
 
Improving the Accumulo User Experience
 Improving the Accumulo User Experience Improving the Accumulo User Experience
Improving the Accumulo User Experience
Accumulo Summit
 
AtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMSAtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMS
NITSAN Technologies Pvt Ltd
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
vstorm83
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphony
Brahampal Singh
 
SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011
Paul Rogers
 
SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011
Paul Rogers
 
MVC = Make Venerated Code?
MVC = Make Venerated Code?MVC = Make Venerated Code?
MVC = Make Venerated Code?
Patrick Allaert
 
ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013
François-Xavier Bonnet
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Steven Smith
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Mack Hardy
 
Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2
3camp
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery Internals
Artur Cistov
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen1
 

Similar to Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - Pug Milano 2013 (20)

eZPublish meets Simfony2 - phpDay2013
eZPublish meets Simfony2  - phpDay2013eZPublish meets Simfony2  - phpDay2013
eZPublish meets Simfony2 - phpDay2013
 
Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHP
 
Building Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHPBuilding Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHP
 
Play Framework
Play FrameworkPlay Framework
Play Framework
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
 
Frankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGiFrankenstein's IDE: NetBeans and OSGi
Frankenstein's IDE: NetBeans and OSGi
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best Practices
 
Improving the Accumulo User Experience
 Improving the Accumulo User Experience Improving the Accumulo User Experience
Improving the Accumulo User Experience
 
AtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMSAtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMS
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphony
 
SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011
 
SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011
 
MVC = Make Venerated Code?
MVC = Make Venerated Code?MVC = Make Venerated Code?
MVC = Make Venerated Code?
 
ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2
 
Front-end optimisation & jQuery Internals
Front-end optimisation & jQuery InternalsFront-end optimisation & jQuery Internals
Front-end optimisation & jQuery Internals
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 

More from Gaetano Giunta

php day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez componentsphp day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez components
Gaetano Giunta
 
phpday 2006 - SEA case study
phpday 2006 - SEA case studyphpday 2006 - SEA case study
phpday 2006 - SEA case study
Gaetano Giunta
 
phpday 2006 - WS in PHP
phpday 2006 - WS in PHPphpday 2006 - WS in PHP
phpday 2006 - WS in PHP
Gaetano Giunta
 
Powerful Automation Made Simple
Powerful Automation Made SimplePowerful Automation Made Simple
Powerful Automation Made Simple
Gaetano Giunta
 
Managing changes to eZPublish Database
Managing changes to eZPublish DatabaseManaging changes to eZPublish Database
Managing changes to eZPublish Database
Gaetano Giunta
 
Symfony vs. Message Brokers
Symfony  vs.  Message BrokersSymfony  vs.  Message Brokers
Symfony vs. Message Brokers
Gaetano Giunta
 
Designing a Docker Stack for Symfony apps: lessons learned
Designing a Docker Stack  for Symfony apps: lessons learnedDesigning a Docker Stack  for Symfony apps: lessons learned
Designing a Docker Stack for Symfony apps: lessons learned
Gaetano Giunta
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
Gaetano Giunta
 
Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and...  Symfony meets queueing brokersRabbits, indians and...  Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokers
Gaetano Giunta
 
Symfony2 for legacy app rejuvenation: the eZ Publish case study
Symfony2 for legacy app rejuvenation: the eZ Publish case studySymfony2 for legacy app rejuvenation: the eZ Publish case study
Symfony2 for legacy app rejuvenation: the eZ Publish case study
Gaetano Giunta
 
Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)
Gaetano Giunta
 
EzPerformancelogger & Graphite
EzPerformancelogger & GraphiteEzPerformancelogger & Graphite
EzPerformancelogger & Graphite
Gaetano Giunta
 
Ez performance measurement
Ez performance measurementEz performance measurement
Ez performance measurement
Gaetano Giunta
 
Ez Content Staging for the rest of us
Ez Content Staging for the rest of usEz Content Staging for the rest of us
Ez Content Staging for the rest of us
Gaetano Giunta
 
An eZ Publish Craftsman's toolchest
An eZ Publish Craftsman's toolchestAn eZ Publish Craftsman's toolchest
An eZ Publish Craftsman's toolchest
Gaetano Giunta
 

More from Gaetano Giunta (15)

php day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez componentsphp day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez components
 
phpday 2006 - SEA case study
phpday 2006 - SEA case studyphpday 2006 - SEA case study
phpday 2006 - SEA case study
 
phpday 2006 - WS in PHP
phpday 2006 - WS in PHPphpday 2006 - WS in PHP
phpday 2006 - WS in PHP
 
Powerful Automation Made Simple
Powerful Automation Made SimplePowerful Automation Made Simple
Powerful Automation Made Simple
 
Managing changes to eZPublish Database
Managing changes to eZPublish DatabaseManaging changes to eZPublish Database
Managing changes to eZPublish Database
 
Symfony vs. Message Brokers
Symfony  vs.  Message BrokersSymfony  vs.  Message Brokers
Symfony vs. Message Brokers
 
Designing a Docker Stack for Symfony apps: lessons learned
Designing a Docker Stack  for Symfony apps: lessons learnedDesigning a Docker Stack  for Symfony apps: lessons learned
Designing a Docker Stack for Symfony apps: lessons learned
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
 
Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and...  Symfony meets queueing brokersRabbits, indians and...  Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokers
 
Symfony2 for legacy app rejuvenation: the eZ Publish case study
Symfony2 for legacy app rejuvenation: the eZ Publish case studySymfony2 for legacy app rejuvenation: the eZ Publish case study
Symfony2 for legacy app rejuvenation: the eZ Publish case study
 
Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)
 
EzPerformancelogger & Graphite
EzPerformancelogger & GraphiteEzPerformancelogger & Graphite
EzPerformancelogger & Graphite
 
Ez performance measurement
Ez performance measurementEz performance measurement
Ez performance measurement
 
Ez Content Staging for the rest of us
Ez Content Staging for the rest of usEz Content Staging for the rest of us
Ez Content Staging for the rest of us
 
An eZ Publish Craftsman's toolchest
An eZ Publish Craftsman's toolchestAn eZ Publish Craftsman's toolchest
An eZ Publish Craftsman's toolchest
 

Recently uploaded

Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 

Recently uploaded (20)

Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 

Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - Pug Milano 2013

  • 1. Case study: eZ Publish Symfony2 http kernel for legacy apps Gaetano Giunta | PUG Milano | Maggio 2013
  • 3.  Existing codebase is 10 years old   High maintenance cost  Started with no unit tests  Layers and roles not properly defined / documented  OOP before php had  Private/protected/static  Closures  Namespaces  Late static binding  And much more  Not built for an Ajax and REST world 5/18/2013gg@ez.no Slide 3 Why change? Everyone loves NEW!
  • 4.  Existing codebase is 10 years old   Widely deployed  Well debugged  Pitfalls have probably been uncovered by now  Proven to scale  Well known:  Documentation improved over years  Tutorials, forums, blogs, aggregators  Active community of practitioners  Official training courses 5/18/2013gg@ez.no Slide 4 Why change? Do not forget drawbacks
  • 5.  Focus on our core business  Experience Management  Content Management  NOT Framework maintenance  DurableArchitecture  API stability  Battle tested / not (only) the latest trend  Scalability  Lively Community! 5/18/2013gg@ez.no Slide 5 Picking a framework for a platform rebuild
  • 6. • Simple Integration with existing API • HMVC (Hierarchical Model View Controller) stack • Decoupled Components • Dependency Injection • Good Template Engine • Extensible, Open, Reliable ;-) 5/18/2013gg@ez.no Slide 6 Prerequisites
  • 7. • Home brew • Zeta Components • Zend Framework 2 • Symfony 2 (Full Stack!) 5/18/2013gg@ez.no Slide 7 Candidates
  • 8. 5/18/2013gg@ez.no Slide 8 And the winner is… Title of presentation is a hint, really...
  • 10. Product Management SCRUM Story: «As an existing user, I don’t want to be pissed off by a new #@!$% version!» 5/18/2013gg@ez.no Slide 10 Backwards compatibility (life sucks)
  • 11. Product Management SCRUM Story: «As an existing user, I don’t want to be pissed off by a new #@!$% version!» • 100% Data Compatible (same DB scheme) • Possibility to include legacy templates in the new ones • Routing fallback • Load legacy content templates with legacy rules • Settings • Access Symfony services from legacy modules 5/18/2013gg@ez.no Slide 11 Backwards compatibility: the objectives
  • 12. Product Management SCRUM Story: «As an existing user, I don’t want to be pissed off by a new #@!$% version!» • 100% Data Compatible (same DB scheme) • Possibility to include legacy templates in the new ones • Routing fallback • Load legacy content templates with legacy rules • Settings • Access Symfony services from legacy modules 5/18/2013gg@ez.no Slide 12 Backwards compatibility: the objectives
  • 14. Product Management SCRUM Story: «As an existing user, I don’t want to be pissed off by a new #@!$% version!» • 100% Data Compatible (same DB scheme) • Possibility to include legacy templates in the new ones • Routing fallback • Load legacy content templates with legacy rules • Settings • Access Symfony services from legacy modules Challenge Accepted 5/18/2013gg@ez.no Slide 14 BC: the challenge
  • 16. Legacy version still works perfectly standalone 5/18/2013gg@ez.no Slide 16 BC: icing on the cake
  • 17. Isn’t this what you have been waiting for? The HTTP Kernel
  • 18. Request => process() => Response use SymfonyComponentHttpFoundationRequest; use SymfonyComponentHttpFoundationResponse; $request = Request::createFromGlobals(); $input = $request->get('name', 'World'); // allows a default value $response = new Response('Hello ' . htmlspecialchars($input, ENT_QUOTES, 'UTF-8')); $response->send(); // takes care of http headers  The HTTPFoundation Component eases mundane tasks 5/18/2013gg@ez.no Slide 18 Use the HTTP, Luke A very, very simple frontend controller
  • 19.  The HTTPKernel component “formalizes the process of starting with a request and creating the appropriate response” interface HttpKernelInterface { const MASTER_REQUEST = 1; const SUB_REQUEST = 2; public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true); }  Returns a Response instance  The «H» in HMVC: subrequests are baked in from the beginning  Looks simple so far, isn’t it? 5/18/2013gg@ez.no Slide 19 The heart of the application
  • 20.  The HttpKernel defines a complex flexible workflow  The controller to execute is found via a ControllerResolver  «Framework» work is done via an event system / event listeners 5/18/2013gg@ez.no Slide 20 Adding the magic
  • 21. $request = Request::createFromGlobals(); $dispatcher = new EventDispatcher(); // ... add some event listeners, eg: routing, security checking // create the controller resolver $resolver = new MyControllerResolver(); // instantiate the kernel $kernel = new HttpKernel( $dispatcher, $resolver ); $response = $kernel->handle( $request ); $response->send(); $kernel->terminate( $request, $response ); 5/18/2013gg@ez.no Slide 21 Building a frontend controller
  • 22.  Any class implementing the ControllerResolverInterface can be used interface ControllerResolverInterface { // must return a callable public function getController(Request $request); // returns an array of arguments for the controller public function getArguments(Request $request, $controller); }  ... 5/18/2013gg@ez.no Slide 22 Finding the Controller
  • 23.  The Event Dispatcher Component can be used use SymfonyComponentEventDispatcherEvent; $dispatcher->addListener('foo.action', $callable);  Depending on returned value, workflow might be altered (see docs online)  Dispatchedevents: Name Name as constant Argument passed to the listener kernel.request KernelEvents::REQUEST GetResponseEvent kernel.controller KernelEvents::CONTROLLER FilterControllerEvent kernel.view KernelEvents::VIEW GetResponseForControllerResultEvent kernel.response KernelEvents::RESPONSE FilterResponseEvent kernel.terminate KernelEvents::TERMINATE PostResponseEvent kernel.exception KernelEvents::EXCEPTION GetResponseForExceptionEvent 5/18/2013gg@ez.no Slide 23 Adding event listeners
  • 25.  New Core: a standard Simfony app («ezpublish» = «app»)  «Legacy Stack» isolated in a dedicated directory 5/18/2013gg@ez.no Slide 25 Refactoring: directory layout
  • 26.  New Core: Sf Bundles 5/18/2013gg@ez.no Slide 26 Refactoring: bundles
  • 27. use SymfonyComponentHttpFoundationRequest; require_once __DIR__ . '/../ezpublish/autoload.php'; // set up class autoloading require_once __DIR__ . '/../ezpublish/EzPublishKernel.php'; $kernel = new EzPublishKernel( 'dev', true ); // extends the Sf Kernel class $kernel->loadClassCache(); // a method from parent class $request = Request::createFromGlobals(); $response = $kernel->handle( $request ); $response->send(); $kernel->terminate( $request, $response );  The Kernel class wraps the HTTPKernel  It adds a Service Container  It allows to register bundles via registerBundles() 5/18/2013gg@ez.no Slide 27 The final frontend controller Using Symfony Full Stack
  • 28.  Sandbox legacy code in a closure  Index.php had to be refactored (from 1100 lines to 20)  Logic moved to a php class  Separated environment setup from execution and teardown  runCallback() sets up the global legacy environment 5/18/2013gg@ez.no Slide 28 Refactoring: bridging Legacy code
  • 30.  eZPublish 4 uses a custom MVC implementation  Frontend controller: index.php  Bootstraps configuration system, logging, “siteaccess”  Controllers are “plain php” files, properly declared  Url syntax: http:// site / module / controller / parameters  Parameters use a custom format instead of the query string  Virtual aliases can be added on top  For all content nodes, a nice alias is always generated by the system  Good for SEO Technical debt  No DIC anywhere (registry pattern used)  No nested controllers  No provision for REST / AJAX  Implemented ad-hoc in many plugins (code/functionality duplication)  Policies are tied to controllers, not to the underlying content model 5/18/2013gg@ez.no Slide 30 Routing
  • 31. 5/18/2013gg@ez.no Slide 31 Routing: seamless integration
  • 32.  The ChainRouter from the Sf CMF project is used  Routes for new controllers can be declared in different ways  In a configuration file  app/config/routing.yml  Mybundle/Resources/config/routing.yml (loaded from main routing file)  Via annotations (phpdoc comments)  needs the SensioFrameworkExtraBundle bundle  Command line to dump them php app/console router:debug  Maximum flexibility for parameters: required/optionsl, default values, validation, restrict http method, extra support for locale and format, ... 5/18/2013gg@ez.no Slide 32 Routing: how it works
  • 34.  eZ Publish 4 has a complicated advanced caching system  For viewing content, cache is generated on access, invalidated on editing  TTL = infinite  When editing a content, cache is also invalidated for all related contents  Extra invalidation rules can be configured  Can be set up to be pregenerated at editing time (tradeoff: editing speed)  Cache keys include policies of current user, query string, custom session data  “Cache-blocks” can also be added anywhere in the templates  Expiry rules can be set on each block, TTL-based or content-editing based  Breaks mvc principle  Most powerful AND misunderstoodfeature in the CMS 5/18/2013gg@ez.no Slide 34 eZ4 Caching: basics
  • 35.  eZ has a built-in “full-page cache” (stores html on disk)  Currently deprecated, in favour of using a caching reverse Proxy  Performances same if not better  Delegate maintenance of part of the stack (Varnish, Squid)  Holy grail of caching: high TTL and support for PURGE command 1. When RP requests page from server, he gets a high TTL => cache page forever 2. When page changes, server tells to RP to purge that url from cache  Best reduction in number of requests to server while always showing fresh data  Downside: extremely hard to cache pages for connected users  ESI support as well  Hard to make efficient, as eZ can not regenerate an ESI block without full page context 5/18/2013gg@ez.no Slide 35 eZ4 Caching: integration with Reverse Proxies
  • 36.  HTTP Expiration and Validation are used  By setting caching headers on response object  Integrates with a Gateway Cache (a.k.a Reverse Proxy)  Native (built-in, php) $kernel = new Kernel('prod', false); $kernel = new HTTPCache($kernel);  External (Varnish, Squid, ...)  Native support for ESI  Using {{ render_esi() }} in twig 5/18/2013gg@ez.no Slide 36 Symfony Caching: basics
  • 37. REST
  • 38.  eZ4 had an incomplete REST API  Only functionality available: reading content  Based on Zeta Components MVC component  A new API has been implemented  Full reading and writing of content is possible  All “dictionary” data is also available  Content-type for response can be JSON or XML (with an XSD!)  Fully restful  Usage of all HTTP verbs (and then some: PATCH)  Respect http headers of request (eg: “Accept”)  HATEOAS: use urls as resource ids  No separate request handling framework needed: pure Symfony routing  Bonus points: a client for the REST API, implements the same interfaces exposed by the local PHP API – network transparency!!! 5/18/2013gg@ez.no Slide 40 REST API
  • 40.  Tutorials:  http://fabien.potencier.org/article/50/create-your-own-framework-on-top-of-the- symfony2-components-part-1  http://symfony.com/doc/current/components/http_kernel/introduction.html  Sf2 book – jolly good looking docs: http://symfony.com/doc/current/book/index.html  eZ Publish:  Community: http://share.ez.no  Source code: https://github.com/ezsystems  API docs: http://pubsvn.ez.no/preview.html  Contact me: @gggeek, gaetano.giunta@ez.no 5/18/2013gg@ez.no Slide 42 The usual suspects