Drupal 8 is now introducing more and more Symfony2 components into its architecture. This will make it possible to use Symfony2 paradigms when building custom modules in Drupal 8. But what if you want to go further and include a standard Drupal 8 inside a Symfony2 project? This presentation shows how to do it in a step-by-step approach and gives more generic advice on how to wrap php application inside a Symfony2 application.
3. 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
7. 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
9. 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
10. 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 »
16. 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
23. THEODO20/09/2013 23
A big picture of how a request is handled by Drupal 8
Drupal 8 architecture
The startis (almost) likeSymfony
24. 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()
26. 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
28. 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
36. 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
46. THEODO20/09/2013 46
How to do this at home
TheodoDrupal8bundle
https://github.com/theodo/TheodoDrupal8Bundle
47. 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
48. 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