웹 응용 프로그램에 서비스 및 클래스 이름 목록이 필요합니다. 나는 콘솔에서이 명령을 사용할 수 있습니다Symfony에서 프로그래밍 방식으로 서비스 목록을 얻는 방법?
php bin/console debug:container
그리고 나는 이런 식으로 뭔가 얻을 :
Symfony Container Public Services
=================================
-------------------------------------------------------------------- --------------------------------------------------------------------------------------------
Service ID Class name
-------------------------------------------------------------------- --------------------------------------------------------------------------------------------
annotation_reader Doctrine\Common\Annotations\CachedReader
app.annotations.softdelete.driver AppBundle\Doctrine\SoftDelete\Mapping\Driver\Annotation
app.annotations.translate.driver AppBundle\Doctrine\Mapping\Driver\TranslateDriver
app.be_auth_controller.listener AppBundle\EventListener\BeAuthControllerListener
나는 내가 만든
심포니 3을 사용하여 웹 페이지에서이 정보를 갖고 싶어를 서비스와 내가 사용 :
$this->container->getServiceIds();
같은 반환
[
0 => "service_container"
1 => "annotation_reader"
2 => "annotations.reader"
3 => "app.annotations.softdelete.driver"
4 => "app.annotations.translate.driver"
...
]
나는 클래스 이름을 얻는 방법을 모르겠다. 어떤 경우
이 작동 :
get_class($this->container->get($this->container->getServiceIds()[1]))
그러나 일부 다른 경우에 다른 예외를 throw
.의견이 있으십니까?
감사합니다.