ezpublish meets simfony2 - phpday2013
TRANSCRIPT
![Page 1: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/1.jpg)
eZPublish meets Symfony
Gaetano Giunta | phpDay 2013 | 17.5.2013
![Page 4: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/4.jpg)
The drivers
![Page 6: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/6.jpg)
Existing codebase is 10 years old
High maintenance cost
Started with no unit tests - singletons everywhere
Layers and roles not properly defined / documented - interdependencies
OOP before php had
Private/protected/static
Closures
Namespaces
Late static binding
And much more
Not built for an AJAX and REST world
5/17/2013 [email protected] Slide 6
Why change? Everyone loves NEW!
![Page 7: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/7.jpg)
Existing codebase is 10 years old
Widely deployed
Well debugged
Pitfalls have mostly 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/17/2013 [email protected] Slide 7
Why change? Do not forget drawbacks
![Page 8: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/8.jpg)
Focus on our core business Experience Management
Content Management
NOT Framework maintenance
Durable Architecture
API stability
Battle tested / not (only) the latest trend
Scalability
Lively Community!
5/17/2013 [email protected] Slide 8
Picking a framework for a platform rebuild
![Page 9: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/9.jpg)
• Simple Integration with existing API
• HMVC (Hierarchical Model View Controller) stack
• Decoupled Components
• Dependency Injection
• Good Template Engine
• Extensible, Open, Reliable ;-)
5/17/2013 [email protected] Slide 9
Prerequisites
![Page 10: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/10.jpg)
• Homebrew
• Zeta Components
• Zend Framework 2
• Symfony 2
5/17/2013 [email protected] Slide 10
Candidates
![Page 13: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/13.jpg)
5/17/2013 [email protected] Slide 13
This is eZ Publish 5!
Standard
Symfony2 App. (=app)
+ eZ Publish
bundles (PHP & REST APIs
+ Legacy)
vendor/
ezsystems/
ezpublish-kernel
+ Full-blown
Back-office
![Page 14: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/14.jpg)
The challenge
![Page 15: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/15.jpg)
Product Management SCRUM Story:
«As an existing user, I don’t want to be pissed off by a new
#@!$% version!»
5/17/2013 [email protected] Slide 15
Backwards compatibility (life sucks)
![Page 16: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/16.jpg)
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/17/2013 [email protected] Slide 16
Backwards compatibility: the objectives
![Page 17: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/17.jpg)
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/17/2013 [email protected] Slide 17
Backwards compatibility: the objectives
![Page 18: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/18.jpg)
A new architecture
![Page 19: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/19.jpg)
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/17/2013 [email protected] Slide 19
BC: the challenge
![Page 21: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/21.jpg)
Legacy version still works perfectly standalone
5/17/2013 [email protected] Slide 21
BC: icing on the cake
![Page 22: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/22.jpg)
Taming the beast
![Page 23: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/23.jpg)
New Core: a standard Simfony app
Legacy stack isolated in a dedicated
directory
5/17/2013 [email protected] Slide 23
Refactoring: directory layout
![Page 24: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/24.jpg)
use Symfony\Component\HttpFoundation\Request;
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/17/2013 [email protected] Slide 24
The new frontend controller Using Symfony HTTP Kernel
![Page 25: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/25.jpg)
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/17/2013 [email protected] Slide 25
Refactoring: bridging Legacy code
![Page 26: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/26.jpg)
The ChainRouter from the Sf CMF project is used
5/17/2013 [email protected] Slide 26
Routing: seamless integration
![Page 27: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/27.jpg)
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/17/2013 [email protected] Slide 27
REST API
![Page 28: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/28.jpg)
An ongoing story
![Page 30: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/30.jpg)
Where to go from here
![Page 31: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/31.jpg)
There’s a few tickets left!
Did I tell you it’s on the sea?
Want to dive in?
5/17/2013 [email protected] Slide 31
![Page 32: eZPublish meets Simfony2 - phpDay2013](https://reader033.vdocuments.mx/reader033/viewer/2022060108/554f4b8fb4c905b9508b492a/html5/thumbnails/32.jpg)
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
Slides soon on Slideshare
Contact me: @gggeek, [email protected]
THANK YOU
5/17/2013 [email protected] Slide 32
The usual suspects