SlideShare una empresa de Scribd logo
1 de 49
THEODO20/09/2013 1
Wrapping PHP in Symfony2
Integrating Drupal8 into Symfony2
THEODO20/09/2013 2
When Drupal8startedrockingthe PHP world
The technical challenges of PHP wrapping
Integrating Drupal8 into Symfony2, step by step
THEODO20/09/2013 3
Drupal usage isgrowing 2x fasterthanWordpress
Drupal’s position in the CMS landscape
• Drupalisused by 2% of the top 1 million
websites, according to W3Techs.com
• +21% growth last year!
To compare withJoomla: +0% and Wordpress:
+11%
• Acquiaexpects$68 million revenue in 2013
with +50% growth
THEODO20/09/2013 4
Drupalpowersmanyinfluentialwebsites
Drupal’s position in the CMS landscape
THEODO20/09/2013 5
Drupalpowersmanyinfluentialwebsites
Drupal’s position in the CMS landscape
THEODO20/09/2013 6
Drupal 8 is due thisyearaftertwoyears of hard work
The new Drupal version
THEODO20/09/2013 7
Drupal 8 is due thisyearaftertwoyears of hard work
The new Drupal version
• 7 core initiatives organized in a Scrum-ishway
• Mobile
• Multilingual
• Layouts
• Views in core
• HTML5
• Web Services
• Configuration Management
• The last phase « API completion » started on July 1st
THEODO20/09/2013 8
Drupal 8 wants to become a content management platform
The web service core initiative
THEODO20/09/2013 9
So Larry started looking for a good Request/Response library
to include in the Web Services core initiative…
The introduction of the HttpKernel
THEODO20/09/2013 10
…and thatiswhenStofchanged the PHP world
How Drupal chose Symfony2
« And thenthis French guyStofspenthours on IRC with me, convincing
me step by stephow all myproblemswouldbesolved by the
HttpKernel. I realisedafterwardsitwasnighttime in France »
THEODO20/09/2013 11
Sincethen Symfony2 istakingover Drupal 8
Symfony2 components adopted by Drupal 8
THEODO20/09/2013 12
Sincethen Symfony2 istakingover Drupal 8
Drufony
THEODO20/09/2013 13
16 000 additionalcontributors to Symfony2!
The power of the Drupalcommunity
THEODO20/09/2013 14
When Drupal8startedrocking the PHP world
The technical challenges of PHP wrapping
Integrating Drupal8 into Symfony2, step by step
THEODO20/09/2013 15
Why is wrapping not as easy as include?
Challenges behindPHP wrapping
THEODO20/09/2013 16
PHP is designed around « one request <-> one process »
Challenges behindPHP wrapping
The consequences of this simple design are obvious:
• Want to output something? echo to STDOUT
• Want to end the request? => exit()
• Want to sharesomethinginside the process? => $GLOBAL
• Want to call two classes with the samename? =>whoneedsthat?
PHP iseverything but Stateless
THEODO20/09/2013 17
Catching the output
THEODO20/09/2013 18
Catching the exits
THEODO20/09/2013 19
Handling globals
THEODO20/09/2013 20
Class and functionconflicts
History of PHP applications
• Write a custom autoloader for classes
• And for functions…
THEODO20/09/2013 21
Handling session alreadystarted
History of PHP applications
THEODO20/09/2013 22
When Drupal8startedrocking the PHP world
The technical challenges of PHP wrapping
Integrating Drupal8 into Symfony2, step by step
THEODO20/09/2013 23
A big picture of how a request is handled by Drupal 8
Drupal 8 architecture
The startis (almost) likeSymfony
THEODO20/09/2013 24
A big picture of how a request is handled by Drupal 8
Drupal 8 architecture
Authentication
• ishandled by AuthenticationSubscriberstartedby the
onKernelRequestAuthenticateevent
• Depends on the AuthenticationManager service
• That choses between the Cookie or HTTPBasic provider
• In the end the Cookie provider justwraps the
legacydrupal_session_initialize()
THEODO20/09/2013 25
A big picture of how a request is handled by Drupal 8
Drupal 8 architecture
THEODO20/09/2013 26
A big picture of how a request is handled by Drupal 8
Drupal 8 architecture
Routing
• Is handled by the CMFChainRouter
• Which looks first in the DynamicRouter and then the
LegacyUrlMatcher
• LegacyUrlMatcherjustwrapsmenu_get_item()
HTMLPageController
• Wrapsdrupal_render_page
THEODO20/09/2013 27
A big picture of how a request is handled by Drupal 8
Drupal 8 architecture
THEODO20/09/2013 28
Let’s start to hack!
Integration plan
Goals
• #1: WrapDrupal in Symfony2
• #2: Access Drupalnodes and session from a Symfony2 controller
THEODO20/09/2013 29
Routingbetween Symfony2 and Drupal
TheodoDrupal8BundleRouterListener
THEODO20/09/2013 30
Routingbetween Symfony2 and Drupal
TheodoDrupal8BundleRouterListener
THEODO20/09/2013 31
Routingbetween Symfony2 and Drupal
TheodoDrupal8BundleRouterListener
THEODO20/09/2013 32
Buffering the kernel
TheodoDrupal8BundleRouterListener
THEODO20/09/2013 33
Cannotredeclareassetic_init()
Class loading issues
THEODO20/09/2013 34
Cannotredeclareassetic_init()
Class loading issues
THEODO20/09/2013 35
Cannotredeclareassetic_init()
Class loading issues
THEODO20/09/2013 36
Symlinks to whatDrupalexpects to be in web root
Assets and symlinks
Symbolic links to modules, profiles, sites and themes
Symbolic links to the samefolders (and justthese) in core
THEODO20/09/2013 37
Change Drupal settings accordingly
Assets and symlinks
THEODO20/09/2013 38
http://sf2drupal/app_dev.php/user works!
Routingdemo
Symfony’s debug toolbar!
Drupal’s new responsive theme
THEODO20/09/2013 39
There isstill a bug in the Symfony profiler…
RequestDataCollector bug
THEODO20/09/2013 40
Corrected in a PULL REQUEST!
RequestDataCollector bug
THEODO20/09/2013 41
Accessevery service fromcore.services.yml
Drupal Service Container
THEODO20/09/2013 42
For example: accessing node content
getNode
THEODO20/09/2013 43
Getting the Drupal connected user
getCurrentUser
THEODO20/09/2013 44
Integrating Drupal 8 into Symfony2
DemoController
THEODO20/09/2013 45
Integrating Drupal 8 into Symfony2!
DemoController
Node content!
Current user name!
THEODO20/09/2013 46
How to do this at home
TheodoDrupal8bundle
https://github.com/theodo/TheodoDrupal8Bundle
THEODO20/09/2013 47
Tips to help you continue integrating
PHP integration
• Good IDE + Xdebug to follow the code
• Put a breakpointaterrorhandlingfunctions, to read the errorinside
the code
• Compare the samefunctionality/page with and withoutwrapping
• Otherinteresting bundle:
https://github.com/theodo/TheodoEvolutionSessionBundle
THEODO20/09/2013 48
What are the next priorities
Nextsteps
• Integration must bringease of adding custom logic in
Symfonycontrollers =>likeRogerCMS
• See how Symfony2 canimproveDrupal 8 performances…
• Session and permission sharing
THEODO20/09/2013 49
Questions ?
fabriceb@theodo.fr
@theodo
www.theodo.fr
Feedback: https://joind.in/9329

Más contenido relacionado

La actualidad más candente

PHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAPPHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAP
webhostingguy
 

La actualidad más candente (10)

PHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAPPHP in the Enterprise … connecting to SAP
PHP in the Enterprise … connecting to SAP
 
Sap to php
Sap to phpSap to php
Sap to php
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimization
 
Jean Paul Ladage Managing Enterprise Content With Plone
Jean Paul Ladage   Managing Enterprise Content With PloneJean Paul Ladage   Managing Enterprise Content With Plone
Jean Paul Ladage Managing Enterprise Content With Plone
 
Drupal presentation
Drupal presentationDrupal presentation
Drupal presentation
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...
 
Php simple
Php simplePhp simple
Php simple
 
Drupal + composer = new love !?
Drupal + composer = new love !?Drupal + composer = new love !?
Drupal + composer = new love !?
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 

Similar a Integrating Drupal 8 into Symfony 2

Similar a Integrating Drupal 8 into Symfony 2 (20)

Drupal
DrupalDrupal
Drupal
 
The Workflow Methodology to Train Your Team on Drupal 8
The Workflow Methodology to Train Your Team on Drupal 8The Workflow Methodology to Train Your Team on Drupal 8
The Workflow Methodology to Train Your Team on Drupal 8
 
Angular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entrepriseAngular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entreprise
 
Website factory with domain Access: why and how& - Kiêt Trân & David Ferlay
Website factory with domain Access: why and how& - Kiêt Trân & David FerlayWebsite factory with domain Access: why and how& - Kiêt Trân & David Ferlay
Website factory with domain Access: why and how& - Kiêt Trân & David Ferlay
 
[DRUPALCON 2022] Open Personalization with Apache Unomi & Mautic (Workshop).pdf
[DRUPALCON 2022] Open Personalization with Apache Unomi & Mautic (Workshop).pdf[DRUPALCON 2022] Open Personalization with Apache Unomi & Mautic (Workshop).pdf
[DRUPALCON 2022] Open Personalization with Apache Unomi & Mautic (Workshop).pdf
 
JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
JUNIPER: Towards Modeling Approach Enabling Efficient Platform for Heterogene...
 
Drupal 8 Upcoming Features
Drupal 8 Upcoming FeaturesDrupal 8 Upcoming Features
Drupal 8 Upcoming Features
 
Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer
 
October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...
October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...
October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...
 
Drupal 7 and RDF
Drupal 7 and RDFDrupal 7 and RDF
Drupal 7 and RDF
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
 
Drupal 8: Most common beginner mistakes
Drupal 8: Most common beginner mistakesDrupal 8: Most common beginner mistakes
Drupal 8: Most common beginner mistakes
 
Drupal 6 to Drupal 8 Migration
Drupal 6 to Drupal 8 MigrationDrupal 6 to Drupal 8 Migration
Drupal 6 to Drupal 8 Migration
 
ZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of itZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of it
 
Fandogh Cloud workshop slides
Fandogh Cloud workshop slides Fandogh Cloud workshop slides
Fandogh Cloud workshop slides
 
How to Migrate Drupal 6 to Drupal 8?
How to Migrate Drupal 6 to Drupal 8?How to Migrate Drupal 6 to Drupal 8?
How to Migrate Drupal 6 to Drupal 8?
 
Schemaorg cmsplugins
Schemaorg cmspluginsSchemaorg cmsplugins
Schemaorg cmsplugins
 
For a Social Local and Mobile Drupal
For a Social Local and Mobile DrupalFor a Social Local and Mobile Drupal
For a Social Local and Mobile Drupal
 
DrupalCon Europe 2020 Low Code
DrupalCon Europe 2020 Low CodeDrupalCon Europe 2020 Low Code
DrupalCon Europe 2020 Low Code
 
MySQL Database Service Webinar: Installing Drupal in oci with mds
MySQL Database Service Webinar: Installing Drupal in oci with mdsMySQL Database Service Webinar: Installing Drupal in oci with mds
MySQL Database Service Webinar: Installing Drupal in oci with mds
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Integrating Drupal 8 into Symfony 2