What is Bun JS, and why it's here to stay

Bun is an all-in-one toolkit for JavaScript and TypeScript applications. The toolkit includes runtime, package manager, bundler, and test runner.

Bun vs Node JS: Features and Performance

Just a few days ago, Bun was released - Bun v1.0 - the first stable version.

The JS community has been really active these last few days. People are playing around with Bun, testing, and doing benchmarks.

Bun goal is to replace Node.js, and it claims that it's better, faster, and simpler to use. It reduces complexity by having a lot of tools built-in.

In this post, I'll compare the two and outline their pros and cons.

How to install PHP 8.3 on MacOS

PHP 8.3 will be released on November 23, 2023.

Until then, you can play around and test the beta versions which are already out. In this post, I'll show you how to install the beta version on your Mac.

How to match URL with Symfony Router

Have you ever needed to get a route name based on a given URL in Symfony? It might be a weird use case, but the RouterInterface in Symfony has the match() method that will help you do just that.

How to delete doctrine entity by ID in Symfony

The easiest way to remove an entity in Doctrine ORM is by using the $entityManager->remove($entity) method and then calling $entityManager->flush().

How to reload ZSH configuration

I've been using Zsh with Oh-My-Zsh for a long time. All MacOS users have the Zsh (Z shell) installed and configured by default. 

My Zsh configuration changes very rarely, but when it does, I need to restart my shell in order for my changes to take effect. Since I'm using tmux I can open a new window (which loads a new Zsh instance), but most of the time, I prefer to reload the current window.

To reload your Zsh (Z shell) .zshrc configuration, you can use the following command

$ exec zsh

How to cache Symfony responses with Cloudflare for free

Caching is a great way to speed up your website and reduce your server load. Why waste energy on pages that rarely change?

ElasticSearch fix 406 Not Acceptable: error

I'm trying to index a document with ElasticSearch PHP client (version 8.8), and I'm getting an error when trying to execute the create document request:

406 Not Acceptable: {"error":"Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported","status":406}

The weird thing is that the client allowed me to create an index, but when I tried to index a document, I got an error...😕

My configuration is:

  • ElasticSearch PHP client: version 8.8
  • ElasticSearch server: version 7.10

How to return JSON response from Symfony Controller

To return JSON response from Symfony Controller, you can use the $this->json(); method or new JsonResponse(['...']);

JSON (JavaScript Object Notation) is a lightweight data interchange format commonly used for transmitting and storing structured data. It consists of key-value pairs and arrays, making it versatile for representing various data types in a human-readable format that can be easily processed by computers. It is widely used in programming and especially in APIs.

Cloudflare API purge cache by URL example

Cloudflare is a great free tool that offers static asset caching out of the box. You can also cache dynamic pages with it, which is quite handy.

Caching things is nice, but invalidating the cache is not a fun business. 

There is this popular quote:

There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton

I've done a little experiment with Cloudflare. I've configured caching in my blog. The post you are reading right now is cached in CF, currently with a TTL (Time to live) of 1 day.

After configuring the cache, a question immediately arose in my mind. If I update an article I'll need to wait for the cache to expire before the modifications become visible to the public, which is not ideal. I want immediate updates, but then I also want caching

So what is the solution? Simple - invalidate the cache each time the blog post is updated. Thankfully, Cloudflare offers free API, which allows you to do just that - purge cached content by URL. The documentation is not quite clear, and the method I've used is not documented 🤔, but it works, trust me.