Services
We've talked a lot about services without really discussing what they are. In Drupal 8, a service is a PHP object that performs some sort of global task. That means they are separated from the specifics of why that task would need to be performed and be able to concentrate solely on how to perform that task. The services exposed by Drupal 8 core can be found in /core/core.services.yml. If you need functionality from the Drupal 8 system, either from core or contrib, you'll be requesting services. From interacting with the database, to making HTTP calls to external systems, to interacting with the cache, all of those are encapsulated in services. Using dependency injection, all you need to do is declare your dependency on them in your ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access