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

drush devel:services

or use its aliases:

drush devel-container-services


drush dcs


drush devel-services

So drush dcs | grep "PART_OF_SERVICE_NAME" will be a good sample to find a serice

| improve this answer | |

The module Devel provides a searchable list (/devel/container/service).

For the command line use Drupal Console:

drupal debug:container
| improve this answer | |
  • That's perfect ! Thanks for help . Also found another solution we can search it at api.drupal.org/api/drupal/services – riju.srk Mar 30 '17 at 12:22
  • Yes, the list online is perfect for core services, but if you search with devel or console locally you'll also get services from installed modules. – 4k4 Mar 30 '17 at 12:34
  • I agree completely,actually I think looking with Devel is better because may be some contributed module provide some service which is not listed online. – riju.srk Mar 31 '17 at 13:47
  • It's too bad the devel list of services doesn't include the methods of those services. :( – liquidcms Apr 23 at 23:35
  • @liquidcms, devel can't replace an IDE. – 4k4 Apr 24 at 6:21

A list of services are available on drupal.org https://api.drupal.org/api/drupal/services/8.9.x

| improve this answer | |

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(...).

enter image description here

| improve this answer | |
  • 1
    Additionally in order for this to work properly you need to set your project as "Drupal project" on PHPStorm. Usually "he" is smart enough to suggest it to you when you create the project the first time. Check this jetbrains.com/help/phpstorm/drupal-support.html to find out more about Drupal's support on PHPStorm. – d70rr3s Jan 20 at 14:46
  • Unfortunately, it seems one cannot stop the animation. It can get a bit annoying. – systemovich Mar 11 at 4:02
  • I will put it in spoiler. – ssibal Mar 11 at 8:51

\Drupal::getContainer()->getServiceIds() is the REPL friendly way of doing this. Also you can use that on your module code etc..

| improve this answer | |

Since Drupal 8 used Symfony so you can run command php vendor/bin/drupal debug:container and this is equivalent in Symfony php bin/console debug:container

| improve this answer | |
  • This isn't necessarily true. I would modify the post to add that drupal-console is required. – mradcliffe May 15 at 13:18

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:

  • Drupal::service()
  • ContainerInterface::get()
  • EntityTypeManager::getStorage()

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,
// ...
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.