PHP, Symfony & Composer

Last update: February 3, 2023


Get the extension of a file:

$ext = pathinfo($path, PATHINFO_EXTENSION);


Get the kernel and the current environment:


Get the current route name:

$routeName = $request->attributes->get('_route');

more at


Force Twig to set the form widget already rendered (because you already use a sub part of it in the page):

{% do form.x.setRendered %}

Get the name of the current route:

{{ app.request.attributes.get('_route') }}

In Twig use "starts with" in your conditions:

{% if var starts with 'data' %} ... 

Ternary syntax:

{{ condition ? 'yes' : 'no' }} {{ condition ? 'yes' }} {{ condition ?: 'no' }}


More stuff coming soon!

Other / oldies

Permission problem? Try:

setfacl -dR -m u:www-data:rwx -m u:$(whoami):rwx dir
setfacl -R -m u:www-data:rwX -m u:$(whoami):rwX dir