PHP, Symfony & Composer
Last update: February 3, 2023
PHP
Get the extension of a file:
$ext = pathinfo($path, PATHINFO_EXTENSION);
Symfony
Get the kernel and the current environment:
$this->container->get('kernel')->getEnvironment();
Get the current route name:
$routeName = $request->attributes->get('_route');
more at symfony.com/doc/routing.html
Twig
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' }}
Composer
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