RAG explained to my mum

Old library with ladder, metaphor for RAG explained simply

Imagine someone who has read every university library in Switzerland. They can answer almost any general knowledge question. But if you ask them what happened at your place last week, or what’s in your internal documents, they have no idea. They weren’t there, and no one showed them. That’s RAG explained simply: the gap this … Read more

A Chrome extension to find unanswered WhatsApp chats

Person holding a smartphone showing a messaging app — illustration for an article about a Chrome extension to find unanswered WhatsApp chats

I recently opened WhatsApp Web and counted: 52 conversations where someone was waiting on a reply from me, lost in hundreds of group chats and notifications. The native filter strip (All / Unread / Favorites / Groups) does not have a “to reply” view. Unread only catches genuinely unread messages, not the ones I opened … Read more

Symfony – Doctrine – How to see where an SQL query is executed

MacBook avec code sur un bureau

When using Doctrine, it is sometimes important to find where a SQL query is executed. To do this, simply activate the following option in the Doctrine configuration doctrine: dbal: default_connection: default # A collection of custom types Types: # example some_custom_type: class: AcmeHelloBundleMyCustomType Connections: # A collection of different named connections (e.g. default, conn2, etc.) … Read more

Install drupal/console on drupal 9

MacBook avec code sur un bureau

The drupal/console package was never made fully compatible with Drupal 9, and its development has now stopped. If you are starting a recent project, the command-line reference is now Drush. The modern solution: Drush Drush is actively maintained and compatible with Drupal 9, 10 and beyond: composer require drush/drush You then access the commands through … Read more

Categories 449

PHP Spaceship Operator <=>

Code sur écran d'ordinateur

A little-known but very useful operator, for example to sort an array, is the spaceship operator: <=> It compares two values and returns an integer (-1, 0, 1) depending on the result. $a < $b returns -1 $a = $b returns 0 $a > $b returns 1 One way to see it is here: https://3v4l.org/WcRSo … Read more

Categories PHP

PHP CS Fixer – How to keep your code clean

Code sur écran d'ordinateur

A really useful tool to keep your code clean is PHP Coding Standards Fixer. It allows us to follow the PHP standards defined in PSR-1, PSR-2, etc. It is also possible to configure it to follow the style of your team with a documentation. The recommended way to install it is outside your code, but … Read more

PHPUnit – How to test a controller that throws an error

Code sur écran d'ordinateur

Let’s say we have a method in a controller like this: /** * @Route(path=”/add”, name=”add”, methods={“POST”}) */ public function add(Request $request,): Response { throw new BadRequestHttpException(‘Error’); } To test that the exception is properly thrown, just write this public function testList(): void { $this->expectException(BadRequestHttpException::class); $client = self::createClient(); $client->catchExceptions (false); $crawler = $client->request( Request::METHOD_POST, ‘/add’ ); … Read more