Answer the question
In order to leave comments, you need to log in
Symfony 3/4: How to access a service from a template?
Hello!
Created my service in Symfony 3.4, example:
<?php
namespace AppBundle\Service;
class Favourites
{
public function parse ($str)
{
return strtoupper($str);
}
}
Answer the question
In order to leave comments, you need to log in
Like this
https://symfony.com/doc/current/templating/global_...
UPD: but if you have simple manipulations, it's better to create your own twig functions/filters
https://symfony.com/doc/current/templating /twig_ex...
You can also access services in these functions/filters.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question