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

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

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

Symfony4 how to create a custom error page 404

Code sur écran d'ordinateur

You have to start by installing the necessary bundle: compose require symfony/twig-pack When done, create the template error404.html.twig templates/ Bundles/ TwigBundle/ Exception/ Error404.html.twig Example of the error404.html.twig template ‘% extends ‘base.html.twig’ %’ ‘% block body%’ <h1>Page not found</h1> <p> The requested page couldn’t be located. Checkout for any URL misspelling or <a href=”{{ path(‘homepage’) }}”>return … Read more

WordPress – how to install wp-cli on Ubuntu

MacBook avec code sur un bureau

Start by downloading wp-cli curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar Then give it the right to be executed chmod +x wp-cli.phar Then move it to /usr/local/bin to be able to use the wp command sudo mv wp-cli.phar /usr/local/bin/wp To use the command, simply go into the folder containing the WordPress installation $ wp NAME Wp DESCRIPTION Manage WordPress … Read more