Is there a way to get the list of the available services in Drupal 8?
to Enhance @4k4 answer, because it returns a lot of services names, if you looking for the specified service name, just pass a part of its name
for instances, if you looking for log services
drupal debug:container | grep "log"
and if you looking for cache services
drupal debug:container | grep "cache"
Drush base Method
or use its aliases:
drush dcs | grep "PART_OF_SERVICE_NAME" will be a good sample to find a serice
in new version you can just do it with
drush dcs PART_OF_SERVICE_NAME
( thanks @Cameron to mention this in comment)
A list of services are available on drupal.org https://api.drupal.org/api/drupal/services/8.9.x
If you are interested to see the available services during development in PHPStorm you can enable the SymfonyPlugin which autocompletes for you the service names (and does much more other handy stuff)
It works both in services.yml and when calling $container->get(...).
There is the PHPStorm Metadata module which can be used to get autocompletion for all services (core, contrib and custom) in PHPStorm. And it also can give you that list.
This module allows to export PHPStorm Advanced Metadata in order to get autocomplete functionality and return type information for next calls:
After installing and enabling it, run
drush phpstorm-metadata:generate and it will generate a file called .phpstorm.meta.php in your Drupal root directory. Inside there is a list of all available services (core, contrib and custom) mapped to their class.
// ... 'theme_handler' => \Drupal\Core\Extension\ThemeHandler::class, 'theme_installer' => \Drupal\Core\Extension\ThemeInstaller::class, 'entity.manager' => \Drupal\Core\Entity\EntityManager::class, 'entity.memory_cache' => \Drupal\Core\Cache\MemoryCache\MemoryCache::class, 'entity_type.manager' => \Drupal\Core\Entity\EntityTypeManager::class, 'entity_type.repository' => \Drupal\Core\Entity\EntityTypeRepository::class, 'entity_type.bundle.info' => \Drupal\Core\Entity\EntityTypeBundleInfo::class, 'entity.repository' => \Drupal\Core\Entity\EntityRepository::class, // ...