Get a list of services programatically I've recently started working with Drupal 8. I'm looking for a way to programatically(no drupal console or other CLI thing) get a list of all the services available.

Since it's built on top of Symfony I figured that the container should have a list of all the available services. Well, I was wrong.

I've searched around and I can't find any specific answers, other than the CLI option, which is not what I'm looking for.

If anybody can point me in the right direction here, I'd be grateful.
You can get all services from the container by using the kernel method getCachedContainerDefinition():

$container = \Drupal::getContainer();
$kernel = $container-&gt;get('kernel');
$services = $kernel-&gt;getCachedContainerDefinition()['services'];
foreach ($services as $service_id =&gt; $value) {
  $service_definition = unserialize($value);
}


Now you can output a list, for example containing the service id and the class name in $service_definition['class'].