Getting Started - Background & Prerequisites (Drupal 8)
Drupal 8 leverages a number of advanced PHP language features and sophisticated 3rd party libraries in order to present 3rd party developers with the most advanced API of any CMS available. While experienced Drupal 7 developers may see some significant changes, much of the basic structure will remain familiar.
If any of the material presented while going through the D8 module developer's walk-through is new to you, then the material below may help. However, a comprehensive knowledge is not necessary to proceed to the D8 module walkthrough.
Object Oriented Programming
OOP, while initially daunting, is now well established as a best practice.
For a general overview of PHP best practices, read through phptherightway.com. Drupal doesn't make use of all the different tools and techniques documented there but it does serve as a great introduction to PHP and the language's many features.
Brush up on your OOP knowledge by reading the official PHP documentation on Classes and Objects as well as some of these other good primers:
- PHP OOP in Full Effect
- Object-oriented programming (on Wikipedia)
- What's Object-Oriented Programming? (Online tutorial at codecademy.com)
- Object-Oriented PHP for Beginners (at tuts+)
- Object Oriented Concepts (at tutorialspoint.com)
- Object Oriented Programming with PHP (at phpro.org)
- Object Oriented Programming in PHP (at youtube.com)
- Foundations of Programming: Object Oriented Design (at lynda.com)
- Must know 12 PHP OOP concepts
- @todo: add more links to good OOP primer material ...
Drupal 8 also makes use of some common design patterns and you'll want to make sure you have a basic understanding of these:
- The Factory Pattern, and Late static bindings
- Software design pattern (on Wikipedia)
- Foundations of Programming: Design Patterns (at lynda.com)
- @todo: add more links to documentation about the patterns we use ...
If you're unfamiliar with the concept of namespacing in PHP, try some of these articles:
- How to use PHP namespaces.
- PHP: Namespaces
- a video on PHP namespaces.
- PHP Namespaces Explained (by Dayle Rees)
- Namespacing in PHP (at tuts+)
In most cases, the drupal code is namespaced based on the module that code belongs to.
Example: namespace for block.module
@todo: explain why sometimes it's Drupal\ and sometimes it's Drupal\\[Controller|Form|Plugin|etc.] and how I should know which to use ...
Although dependency injection is really just another OOP design pattern we call it out here because Drupal 8 makes heavy use of the concept and it is important to have a baseline understanding in order to access and make use of many of the core APIs.
Read up on dependency injection on PHP the right way, as well as the additional articles linked on that page. Especially this article because Drupal makes heavy use of the Symfony 2 service container referenced.
Symfony 2 is a PHP framework that Drupal borrows from in order to reduce code duplication across various PHP projects. Much of the code that Drupal 8 uses to handle routing, sessions and the services container, amongst other things, is borrowed from Symfony 2. If you want to know more about why this decision was made, check out this presentation by core-committer alexpott for some background.
Check out the Symfony 2 book and brush up on your Symfony knowledge. While not all of it is required to understand Drupal, knowing how Symfony works will make you both a better Drupal developer and a better PHP developer. You might also be interested in the Symfony Glossary.
Drupal 8 makes use of PHP annotations -- @docblock comments added to your code using a special syntax -- for plugin discovery and to provide additional context/meta-data for code that's being executed. Annotations are read using the Doctrine annotation parser then turned into information that Drupal can use to better understand what your code is doing.
Read more about the use of annotations for plugin discovery.
See a list of all the different annotation types in Drupal 8.
See also: PHPDoc (on Wikipedia)
@todo: link to some documentation that explains places in D8 that annotations are used, what they are used for, and how you can figure out what you can/should put into your annotations ...
Plugins provide small pieces of functionality in such a way that they can be easily swapped out for another plugin. Plugins that perform similar functionality are of the same plugin type. For example, 'Field widget' is a plugin type, and each different field widget (text field, textarea, date) is implemented with a plugin.
Read more about the Plugin API in Drupal 8.
@todo: What are these, when do you use them, etc?
Below is a list of additional resources to help ensure that you hit the ground running with Drupal 8.