Object-oriented PHP utilizes classes and objects to organize code into reusable chunks. This approach helps us organize complex applications, such as Drupal, into modular code called classes that can be reused across the entire system. As a module developer, knowledge of object-oriented PHP is essential in order to understand the architecture of a module and the various forms it can take as well as how to implement custom functionality.
Learning modern object-oriented PHP practices is a skill that will benefit you not only as a Drupal 8 developer but also as a PHP developer. If you have a doubt about a certain feature working on your project, check php.net to see which versions of PHP are supported. Also, verify your version of PHP on your localhost as well as your web host.
- What's New in Drupal 8: Object-oriented PHP
- This tutorial provides a high-level overview of the major shift in Drupal 8 to an object-oriented architecture and was created to help you understand which concepts and terminology you will need to learn in order to interact with Drupal at a code level.
- Introduction to Object-Oriented PHP
- This series introduces important concepts in object-oriented PHP, like classes, methods, objects, type hinting and class constructors.
- Object-oriented PHP Part 2
- This second series covers the concepts of service classes, fetching objects from the database, centralizing configuration and the service container (see also Dependency Injection and the Art of Services and Containers).
- Object-oriented PHP Part 3
- The third series in this set explores inheritance in PHP through abstract classes and methods. It also takes a look at how to create and implement interfaces.
- Object-oriented PHP Part 4
- The final series about OOP works with static methods, namespaces, exceptions, traits, autoloading, and more.
- Preparing for Drupal 8: PSR-4 Autoloading
- Drupal 8 uses the PSR-4 standard to allow your PHP classes to be automatically discovered and loaded by following a convention for class namespace and file/directory naming.
- Services topic and Dependency Injection topic
- Learn more about the dependency injection or services container and special PHP classes called services.