Code snippets

You will find here 18 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 ™.

This snippet shows how to activate and inspect MySQL or MariaDB logs. For example, This is useful for checking the queries run by ...

MySQL

Published on 2024-07-20 • Modified on 2024-07-20

 View the code


This snippet shows how to inject the APP_ENV and APP_DEBUG parameters in your Symfony services (or your controllers) with a bind. ...

Symfony

Published on 2024-04-13 • Modified on 2024-04-13

 View the code


This snippet shows how to debug a variable with a concise stack trace with the Symfony VarDumper. The debug_print_backtrace() func...

Symfony

Published on 2023-04-28 • Modified on 2023-04-28

 View the code


This snippet shows how to get the meaning of HTTP response codes with Symfony. It can be done with the help of the Response class ...

Symfony

Published on 2023-03-06 • Modified on 2023-03-06

 View the code


This snippet shows how to get the name of a Twig template inside a Twig template. Yes, this is inception! Not so hard as there is...

Twig

Published on 2023-02-18 • Modified on 2023-02-18

 View the code


This snippet shows how to deactivate the profiler (debug bar) simultaneously wit the debug mode with Symfony. We can use this litt...

Symfony

Published on 2023-01-02 • Modified on 2023-01-02

 View the code


This snippet shows how to force the output of the Symfony debug functions for CLI. When using the dd() and dump() functions, the o...

Symfony

Published on 2022-12-13 • Modified on 2022-12-13

 View the code


This snippet shows how to check if a variable is an enumeration. No is_enum() function exists because is_*() functions don't app...

PHP

Published on 2022-12-09 • Modified on 2022-12-09

 View the code


This snippet shows how to get the calling function name in a debug message with PHP. That's a common need when you want to log or ...

PHP

Published on 2022-09-22 • Modified on 2022-09-22

 View the code


This snippet shows how to list modified files in the vendor directory with composer. We all did it! Modifying files in the vendor ...

composer

Published on 2022-08-01 • Modified on 2022-08-01

 View the code