Behat tutorial part 2: testing Symfony 6 application

In part 1 we saw how to write a behat test. It's now time to use this knowledge to test our real-world application! Please notice that this tutorial will work with most versions of Symfony since behat is compatible with Symfony 4, 5, and 6. The project we are going…

Behat tutorial part 1: the basics

TL;DR: we are going to functionally test the ls command, the code is here. Behat is a testing tool for PHP. But before understanding what behat is used for, you need to understand that different types of testing exist. ⚠️ I will try to explain here the differences between the…

Deploy Ghost 5 using docker compose and traefik

Have your ghost blog engine running in only a few minutes! Here's our configuration if you want some inspiration. We are using docker compose, traefik, and an SQLite database. Our configuration docker-compose.yml version: '3.1' services: ghost: image: ghost:5.x.x-alpine restart: always volumes: - /data/swag-ghost/content:…

Creating a PHP archive (phar)

Java has jar files. PHP has phar files. Those files are PHP projects packaged. You may know them through usages like composer or PHPUnit. But phar files were designed by taking into consideration the nature of PHP: the web. Therefore, we're going to try to show how to build a…

Test emails with Symfony

Symfony 4 brought us the awesome Mailer Component. Something that you may not know about it, is how to test if an email has been sent. This is something not well known, but actually easy! Let's see together how to do it with PHPUnit, but also with Behat - since…

How to get the real PHP memory usage on macOS

PHP provides the function memory_get_usage(), this is very helpful whenever you find your code using a lot of RAM. But this method has a significant limitation: it only counts memory used by your code directly and nothing out of the zend engine. The problem is that you may…

Debunking btrfs

btrfs means no evil! btrfs is awesome! A few weeks ago I listened to one of the Linux Unplugged podcasts about btrfs. It was a reminder that btrfs is great. I have been using btrfs for a few months now, so here is my comment. For those who aren't familiar…

Simple strategy pattern with Symfony

The strategy pattern is a very easy implementation with the DIC from Symfony. Here is how: First let's define an interface for our strategies: namespace App\Domain\CustomProcess; interface MyStrategyInterface { public function execute(Whatever $input); public function supports(Whatever $input); } Then, we will add the tag app.my_strategy in…