Code snippets
You will find here 20 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 ™.
In this snippet, we see how to retrieve a Doctrine entity's changeset after an update. This is essential to know when using Doctri...
Doctrine
Published on 2021-04-21 • Modified on 2021-04-21
In this snippet, we will see how to test if a Doctrine entity has been modified from its initial state in the database. We must us...
Doctrine
Published on 2020-12-18 • Modified on 2020-12-18
In this snippet, we will see how to get the fields and associations list of a Doctrine entity. First, we get the meta class of the...
Doctrine
Published on 2020-08-01 • Modified on 2020-08-01
In this snippet, I will show you the changes I add to make on my configuration when I upgraded Doctrine Migrations from v2.x to v3...
Doctrine
Published on 2020-07-18 • Modified on 2020-07-18
In this snippet we will see how to run raw SQL queries via the Doctrine DBAL connection instance. In the first example, we prepare...
Doctrine
Published on 2020-01-16 • Modified on 2020-01-16
When having to process a large number of rows with Doctrine, it's not a good idea to use the standard getResult function as you ru...
Doctrine
Published on 2019-11-16 • Modified on 2019-11-27
[Edit 2022-04-27] I use PHP 8 attributes now, click on the "read the doc" link to see a relevant example. 🙃 This is a small trick...
Doctrine
Published on 2019-11-07 • Modified on 2022-04-27
[Edit 2020-02-19] Please read my blog post on this topic. This is was my preferred way to declare and use Doctrine repositories. ...
Doctrine
Published on 2019-08-27 • Modified on 2020-02-17
The trick here is that the like must be in the where clause andWhere() whereas the wildcard character % must be passed to the setP...
Doctrine
Published on 2019-01-08 • Modified on 2019-01-08
This code is called from an action function of a Symfony 4.1 standard controller (extending Symfony\Bundle\FrameworkBundle\Control...
Doctrine
Published on 2018-09-11 • Modified on 2018-09-23