PHP

misc

$ext = pathinfo($path, PATHINFO_EXTENSION);

Symfony

Get the environment

$this->container->get('kernel')->getEnvironment();

Permission problem?

sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs

Twig

Get the name of the current route

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

ternary

{% if var starts with ‘data’ %} {{ condition ? ‘yes’ : ‘no’ }} {{ condition ? ‘yes’ }} {{ condition ?: ‘no’ }}