Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

DrupalCamp Ghent 2014 - Developing Drupal 7 with Drupal 8 in mind

647 views

Published on

Code samples used in the presentation: https://github.com/Ozmodiar/Drupal-DIC-Presentation

These are the slides of the presenation I gave at DrupalCamp Ghent 2014 about developing Drupal 7 with Drupal 8 in mind. A session about how we managed to do Drupal development with object-oriented custom modules and Composer and Symfony Container integration. All to provide an easier migration to Drupal 8 later on.

Published in: Software
  • Be the first to comment

DrupalCamp Ghent 2014 - Developing Drupal 7 with Drupal 8 in mind

  1. 1. Develop a Drupal 7 project with Drupal 8 in mind Joeri van Dooren
  2. 2. WHOAMI Who Am I Joeri van Dooren Technical Coach @ SAGA Consulting Group @Ozmodiar https://www.drupal.org/u/ozmodiar
  3. 3. SAGA Consulting Group
  4. 4. Context • Long life span • A lot of custom code • A lot of developers • Drupal 8 vs Drupal 7
  5. 5. Challenges • Migration of custom code to D8 • External libraries • “Big project syndrome”
  6. 6. Code sample: D7
  7. 7. Setup The problems… • Unreadable • Unmaintainable • Not testable (enough) • Not upgradable Vanilla Drupal 7 Object Oriented Code
  8. 8. Setup Vanilla Drupal 7 What have we done? • xautoload module • Drupal 8 class structure Object Oriented Code
  9. 9. Code sample: OO
  10. 10. Setup The problems… • Always re-instantiating classes • Not very maintainable • Not the D8 way Vanilla Drupal 7 Object Oriented Code Dependency Injection
  11. 11. Setup Vanilla Drupal 7 Object Oriented Code Dependency Injection What have we done?
  12. 12. Code sample: DI
  13. 13. Setup This is better, but… • Still not very readable • Not flexible enough • More D8 style, but… • D8 has a better solution Vanilla Drupal 7 Object Oriented Code Dependency Injection Container
  14. 14. Vanilla Drupal 7 Setup Object Oriented Code Dependency Injection Container What have we done? • Custom module • Symfony Container • D8 uses that too! • Copy paste library • xautoload module
  15. 15. Code sample: Container
  16. 16. Setup This is way better but… • Bad library maintenance • D8 has a better solution! Vanilla Drupal 7 Object Oriented Code Dependency Injection Container Dependency Manager
  17. 17. Vanilla Drupal 7 Setup Object Oriented Code Dependency Injection Container Dependency Manager What have we done? • Introduced Composer • Better library management • Libraries not in VCS • Drupal 8 uses that too!
  18. 18. Composer • Package Manager • Packagist.org or other VCS • composer.json • Vendor folder • Autoloading
  19. 19. Code sample: Composer
  20. 20. Setup Vanilla Drupal 7 Object Oriented Code Dependency Injection Container Dependency Manager
  21. 21. Achievements • Easy external libraries • More Drupal 8 compliant • Object Oriented • Module structure • DI with Symfony Container • Less steep learning curve for D8 module dev
  22. 22. Extra advantages • Readability • Maintainability • Extensibility • Easy debugging • Better testing • We got off the island (in D7!)
  23. 23. Points of attention • Developers need a new mindset • Work around D7 limitations • Different code reviews
  24. 24. The next level • Run your own Packagist (or Satis) • Write your own interfaces to improve code reviews • Write modules as libraries with a Drupal module as adapter
  25. 25. More info Getting started http://www.saga.be/dic Extras http://youtu.be/GF0EWdsPfZ4 (dependency Injection) https://getcomposer.org http://symfony.com/doc/current/book/service_container.html
  26. 26. Want to know more? Visit SAGA at our booth
  27. 27. Want to know more? Tomorrow, because now:
  28. 28. Questions?

×