Your SlideShare is downloading. ×
Integrating Drupal 8 into Symfony 2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Integrating Drupal 8 into Symfony 2

6,040
views

Published on

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 …

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.

Published in: Technology

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,040
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
54
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. THEODO20/09/2013 1 Wrapping PHP in Symfony2 Integrating Drupal8 into Symfony2
  • 2. THEODO20/09/2013 2 When Drupal8startedrockingthe PHP world The technical challenges of PHP wrapping Integrating Drupal8 into Symfony2, step by step
  • 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
  • 4. THEODO20/09/2013 4 Drupalpowersmanyinfluentialwebsites Drupal’s position in the CMS landscape
  • 5. THEODO20/09/2013 5 Drupalpowersmanyinfluentialwebsites Drupal’s position in the CMS landscape
  • 6. THEODO20/09/2013 6 Drupal 8 is due thisyearaftertwoyears of hard work The new Drupal version
  • 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
  • 8. THEODO20/09/2013 8 Drupal 8 wants to become a content management platform The web service core initiative
  • 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 »
  • 11. THEODO20/09/2013 11 Sincethen Symfony2 istakingover Drupal 8 Symfony2 components adopted by Drupal 8
  • 12. THEODO20/09/2013 12 Sincethen Symfony2 istakingover Drupal 8 Drufony
  • 13. THEODO20/09/2013 13 16 000 additionalcontributors to Symfony2! The power of the Drupalcommunity
  • 14. THEODO20/09/2013 14 When Drupal8startedrocking the PHP world The technical challenges of PHP wrapping Integrating Drupal8 into Symfony2, step by step
  • 15. THEODO20/09/2013 15 Why is wrapping not as easy as include? Challenges behindPHP wrapping
  • 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
  • 17. THEODO20/09/2013 17 Catching the output
  • 18. THEODO20/09/2013 18 Catching the exits
  • 19. THEODO20/09/2013 19 Handling globals
  • 20. THEODO20/09/2013 20 Class and functionconflicts History of PHP applications • Write a custom autoloader for classes • And for functions…
  • 21. THEODO20/09/2013 21 Handling session alreadystarted History of PHP applications
  • 22. THEODO20/09/2013 22 When Drupal8startedrocking the PHP world The technical challenges of PHP wrapping Integrating Drupal8 into Symfony2, step by step
  • 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()
  • 25. THEODO20/09/2013 25 A big picture of how a request is handled by Drupal 8 Drupal 8 architecture
  • 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
  • 27. THEODO20/09/2013 27 A big picture of how a request is handled by Drupal 8 Drupal 8 architecture
  • 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
  • 29. THEODO20/09/2013 29 Routingbetween Symfony2 and Drupal TheodoDrupal8BundleRouterListener
  • 30. THEODO20/09/2013 30 Routingbetween Symfony2 and Drupal TheodoDrupal8BundleRouterListener
  • 31. THEODO20/09/2013 31 Routingbetween Symfony2 and Drupal TheodoDrupal8BundleRouterListener
  • 32. THEODO20/09/2013 32 Buffering the kernel TheodoDrupal8BundleRouterListener
  • 33. THEODO20/09/2013 33 Cannotredeclareassetic_init() Class loading issues
  • 34. THEODO20/09/2013 34 Cannotredeclareassetic_init() Class loading issues
  • 35. THEODO20/09/2013 35 Cannotredeclareassetic_init() Class loading issues
  • 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
  • 37. THEODO20/09/2013 37 Change Drupal settings accordingly Assets and symlinks
  • 38. THEODO20/09/2013 38 http://sf2drupal/app_dev.php/user works! Routingdemo Symfony’s debug toolbar! Drupal’s new responsive theme
  • 39. THEODO20/09/2013 39 There isstill a bug in the Symfony profiler… RequestDataCollector bug
  • 40. THEODO20/09/2013 40 Corrected in a PULL REQUEST! RequestDataCollector bug
  • 41. THEODO20/09/2013 41 Accessevery service fromcore.services.yml Drupal Service Container
  • 42. THEODO20/09/2013 42 For example: accessing node content getNode
  • 43. THEODO20/09/2013 43 Getting the Drupal connected user getCurrentUser
  • 44. THEODO20/09/2013 44 Integrating Drupal 8 into Symfony2 DemoController
  • 45. THEODO20/09/2013 45 Integrating Drupal 8 into Symfony2! DemoController Node content! Current user name!
  • 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
  • 49. THEODO20/09/2013 49 Questions ? fabriceb@theodo.fr @theodo www.theodo.fr Feedback: https://joind.in/9329