I am new with Symfony and I've searched a lot on the net how to use core PHP functions like array functions (in_array , array_combine) , string functions (strpos , strlen) , date functions (date,timestamp),etc.. In Symfony Twig file?
相关问题
- Symfony2 Set Controller in the kernelControllerEve
- Webpack Encore: cannot import local dependencies
- Render custom attribute KNP Menu
- Problems with cap deploy a symfony2 project, can
- Allow CORS on symfony 4
相关文章
- Symfony : Doctrine data fixture : how to handle la
- Symfony is linked to the wrong PHP version
- Symfony2: check whether session exists or not
- Is there a way to modify the entity mapping config
- symfony2 form choice and mongodb
- What is the Twig equivalent of isset() and !empty(
- Symfony 3.1 and OneUpUploaderBundle + Blueimp = Up
- Symfony does not remove entity from collection
Firstly, create
Twig/Extension
directory into your bundle. Sample:AppBundle/Twig/Extension
Then, create a class for your function name. I create a
JsonDecode
and i use every twig file this function;Then,
add lines into
services.yml
;that's enough.
You have to create a custom twig extension that you could use in your twig template.
You can follow the symfony documentation