Jean-Pierre Lambelet

Dev tips I've been jotting down at work since 2014. Currently at Liip in Lausanne, building the LiipGPT RAG platform.

  • AI / RAG
  • Symfony
  • PHP
  • Drupal
  • Docker

About LinkedIn

Latest articles

RAG explained to my mum

Rayonnages de bibliothèque, métaphore du RAG

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 exactly the problem with ChatGPT or … Read more

Symfony – Doctrine – How to see where a 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

Currently the drupal/console module is not updated for Drupal 9. To be able to use it you have to pass some flags to Composer composer require drupal/console:~1.0 –prefer-dist –optimize-autoloader –sort-packages –no-update composer update The issue regarding this bug is still open: https://github.com/hechoendrupal/drupal-console/issues/4220

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

PHPunit: How to test a controller which 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 */ 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 ( … Read more

MacOsx install php7.4 and force its use

MacBook Pro affichant du code

Start by installing homebrew /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)” Next, use the following commands brew installs php@7.4 brew link –force php@7.4 brew services start php@7.4 export PATH”/usr/local/opt/php@7.4/bin:$PATH” export PATH”/usr/local/opt/php@7.4/sbin:$PATH” Once this is done, check that the PHP version is correct php -v PHP 7.4.13 (cli) (built: Nov 30 2020 14:46:04) ( NTS ) Copyright (c) … Read more