Module Development

Locate and Identify Existing Services for Drupal 8, 9, 10, and 11

To access services in Drupal through the service container, you'll need to know the unique machine name of the service. We'll use the example of making HTTP requests to a weather forecast API in the anytown module to demonstrate several methods you can use to identify an existing service's ID.

In this tutorial, we'll:

  • Discover existing services and their machine names.
  • Take a look at an example service definition.

By the end of this tutorial, you should be able to locate and use existing services in your Drupal module.