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.

Drupal 8 Vocabulary Lesson


Published on

To those of us Drupal developers getting started with Symfony, there's a whole new set of vocabulary words we need to learn. In this SlideShare presentation, I cover a few of the key things you need to know about the new terminology in Drupal 8 including:
-Dependency Injection
-Service Containers

Published in: Technology
  • Be the first to comment

Drupal 8 Vocabulary Lesson

  1. 1. Drupal 8 Vocab Lesson By: Derek DeRaps, Senior Drupal Developer
  2. 2. Development ● Drupal Support ● Custom Module Development ● Large Scale Systems Integration ● Security & Performance Expertise Design/Theming ● Usability Testing ● Responsive Design ● Drupal Theming ● Annotated Wireframes @Mediacurrent We help organizations build highly impactful, elegantly designed Drupal websites that achieve the strategic results you need. Digital Strategy ● Content Strategy ● Content Generation ● Result Metrics ● Marketing Automation Integration
  3. 3. ● YAML ● Composer ● PSR-4 ● Dependency Injection ● Service Containers ● Routing Agenda @Mediacurrent
  4. 4. @Mediacurrent define: “yammel”
  5. 5. @Mediacurrent YAML “Yet Another Markup Language” “YAML Ain't a Markup Language” Used to define .info files and other configuration Hands-on: Let’s create a .info file for our error_notifier module
  6. 6. @Mediacurrent define: Composer
  7. 7. @Mediacurrent Composer “Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.” In Drupal-speak: Does the work formerly handled by the Libraries module (and much more). Important links: Hands-on: Let’s add the Swiftmailer library to our project.
  8. 8. @Mediacurrent define: PSR-4
  9. 9. @Mediacurrent PSR-4 A standard for autoloading classes. No more include or require statements (for the most part). Classes’ namespaces correspond to their location on disk. Your classes’ namespaces always start with Drupalyour_module On disk, that looks like docroot/modules/custom/your_module/src/YourClass.php Class names correspond to filename class MyClass { … } resides in MyClass.php Hands-on Let’s declare a namespace and use other classes in our demo.
  10. 10. @Mediacurrent define: Dependency Injection
  11. 11. @Mediacurrent Dependency Injection “Declaratively express dependencies in the class definition rather than instantiating them in the class itself.” E.g., pass a Transport Interface to the Mailer class; it doesn't need to know whether it’s using SMTP, Sendmail, NullMailer, etc. “The less your code knows, the more reusable it is.” (Sometimes, being ignorant is a good thing.) DI aims to help make our code: Clutter-free, Reusable, Testable Awesome DrupalCon session by Kat Bailey:
  12. 12. @Mediacurrent define: Service Container
  13. 13. @Mediacurrent ● Service ○ any PHP object that performs some sort of “global” task. ● Service Container (aka dependency injection container) ○ a PHP object that manages the instantiation of services (i.e. objects). ● Examples: ○ EventSubscriber (“listens” for events …”Observer” OO pattern). ● Hands-On: ○ Let’s create an EventSubscriber service to send mail on 404 errors. This might replace logic in (D7) hook_page_delivery_callback_alter Service Container
  14. 14. @Mediacurrent define: Routing
  15. 15. @Mediacurrent Routing Think: hook_menu (which is still available FYI). Hands-on Let’s declare a route and then implement its Controller.
  16. 16. Thank You! Questions? @Mediacurrent