Code snippets
You will find here 113 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 get the Symfony minor version of a project. Be careful; this will not work any more as of Symfony 10! ...
Symfony
Published on 2024-12-21 • Modified on 2024-12-21
This snippet shows how to generate a random color code with Symfony. We can use the ByteString::fromRandom() function of the Stri...
Symfony
Published on 2024-12-11 • Modified on 2024-12-11
This snippet shows how to retrieve the list of controllers' FQNC of a Symfony application. We can use this handy getAliases() func...
Symfony
Published on 2024-09-14 • Modified on 2024-09-14
This snippet shows how to convert a CSV file into Symfony entities. Instead of manually setting each property, we can use the Symf...
Symfony
Published on 2024-07-21 • Modified on 2024-07-21
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
In the previous snippet, we saw how to list files of a directory and its subfolders with the RecursiveDirectoryIterator SPL class...
Symfony
Published on 2024-02-13 • Modified on 2024-02-13
This snippet shows how to test a new Symfony major beta version. We saw how to try the "next" minor version in the previous snippe...
Symfony
Published on 2023-11-01 • Modified on 2023-11-01
This snippet shows how to install a Symfony beta version with the Symfony binary. Note that if a new major version is released, it...
Symfony
Published on 2023-10-28 • Modified on 2023-10-28
In the previous snippet, we saw how to inject the Symfony project root directory in the services with a bind. We can also use a P...
Symfony
Published on 2023-09-29 • Modified on 2023-09-29
This snippet shows how to inject the Symfony project root directory in your services (or your controllers) with a bind. In a previ...
Symfony
Published on 2023-09-28 • Modified on 2023-09-28