Q
Q
Quber2013-11-02 09:49:43
symfony
Quber, 2013-11-02 09:49:43

How to use your service in Symfony 2 php template engine?

$foo = $this->get('foo');
This code works in the controller. However, if used in a php template engine, it gives

The helper "foo" is not defined.

The following is written in services.yml:
services: foo: class: App\CoreBundle\Classes\Foo
Thanks in advance…

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MuXaJIbI4, 2013-11-02
@MuXaJIbI4

so get your service in controller and pass it to template

K
Koc, 2013-12-17
@Koc

Need to use Twig Globals

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question