Drupal 8 Services and Services Container Explained
When working in Drupal 8, chances are that you are coming from a different programming language background. PHP and Symphony framework are somewhat different architecturally compared to ASP.Net or Node.js etc.
In this short article, the Services and Services Containers will be explained to give a slight glimpse of its use in Drupal 8 Development. Stick around for reference links in case you want to explore and read more about the topic.
- Services in Drupal 8 can be looked as just objects to manage Dependency Injection, for example, when you pass a class object in another class's Constructor it is important that the class object passed in as an argument not be tightly coupled to the Parent class or else you wouldn't use the class without instantiating a newClassObject to pass in as a parameter.
- According to Drupal.Org, Services provide another layer of abstraction that can handle exceptions on different levels (Paraphrased). When a Developer wants to access the Database, instead of using a PHP inbuilt API to access MySQL, the service will know if the Schema is MySQL or SQL-light.
Edit this Article