Code snippets

You will find here 8 code snippets I find useful so I don't have to Google ™ or Stackoverflow ™ them when I need. There are also code snippets I always forget! 😁 Sometimes, related links to the code will be available. The main difference with other random snippets you will find on the web is that in most cases (for the Symfony related ones) you will be able to run them directly from this website to check the output so you can verify it works as expected ™.

The function is not explode like in PHP. Instead, we can use the split filter (that internally uses ...

Twig

Published on 2020-02-10 • Modified on 2020-02-10

 View the code


In this snippet, we will see how to manually render checkboxes of a form with Twig. This can be usef...

Symfony

Published on 2020-01-21 • Modified on 2020-01-21

 View the code


Sometimes, it's useful to know the current route name in a Twig template. For example in a layout wh...

Symfony

Published on 2020-01-09 • Modified on 2020-01-09

 View the code


This is another example where the constant Twig function can be helpful. In this case we get the \Da...

Twig

Published on 2019-08-18 • Modified on 2019-08-18

 View the code


This is another example where the constant Twig function can be helpful. In this case we get the JSO...

Twig

Published on 2019-08-17 • Modified on 2019-08-17

 View the code


Sometimes when using the PHP date function you need to use characters how are usually reserved to be...

Twig

Published on 2019-08-14 • Modified on 2019-08-14

 View the code


Sometimes it's useful to know if a form is valid inside a Twig template. Indeed, when using the form...

Symfony

Published on 2019-07-23 • Modified on 2019-11-08

 View the code


Well, it's in fact the Twig helper that I am using on this website to show all the snippets. You alr...

Symfony

Published on 2019-02-08 • Modified on 2019-02-10

 View the code