我想在我的Web应用程序中有一个服务和类名列表。 我可以在控制台中使用此命令: p>
php bin / console debug:container
code> pre>
我得到的东西 像这样: p>
Symfony Container Public Services
============================= ======
---------------------------------------- ---------------------------- ---------------------- -------------------------------------------------- --------------------
服务ID类名
---------------------- ---------------------------------------------- ---- -------------------------------------------------- --------------------------------------
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 \ n app.be_auth_controller.listener AppBundle \ EventListener \ BeAuthControllerListener
code> pre>
我想在使用Symfony 3的网页上获取此信息。 p>
我创建了一项服务并使用了: p>
$ this-> container-> getServiceIds();
code> pre>
返回类似于: p>
[
0 => “service_container”
1 => “annotation_reader”
2 => “annotations.reader”
3 => “app.annotations.softdelete.driver”
4 => “app.annotations.translate.driver”
...
]
code> pre>
我不知道,如何获取类名。 p >
在任何情况下都可以这样做: p>
get_class($ this-> container-> get($ this-> container-> getServiceIds()[1]))
code> pre>
但在其他一些情况下它会引发不同的异常。 p>
你有没有 想法? p>
谢谢。 p>
div>