Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道我可以通过在 Twig 模板(示例app.request.host)中使用点符号来访问已注册的服务。但是,如果我创建了自己的命名空间服务(在本例中tagframe.photoservice),当我尝试访问它时,我会收到一个错误,即对象“Silex\Application”上不存在方法“tagframe”。是否可以访问已命名空间的服务?换句话说,我通常会在控制器中使用 $app['tagframe.photoservice'] 访问的服务?
app.request.host
tagframe.photoservice
是的,就像访问数组一样:
{{ app["tagframe.photoservice"].resizePhoto() }}