Named arguments in PHP 8

Thu 23, Jul 2020


One of the coolest new features of PHP 8 are named arguments (parameters). I'm really happy that they made it into PHP 8, as they're a huge improvement syntax-wise, I think. But first, take a look at what they look like:

class Post {

    public function __construct(
        string $title,
        string $body,
        string $author
    ) {}


# ...

$post = new Post(
    title: 'Some interesting post',
    body: 'Bla bla body text here',
    author: 'John'


While this feature was highly debated, I think it comes with far more advantages than disadvantages. It allows for cleaner and easier to understand code (think (min: 0, max: 86400) instead of (0, 86400)). It also allows us to skip default values. Say we have the following function:

function cacheText(
    string $key,
    string $value,
    int $expires = 86400,
    string $directory = 'cache/'
) {}

If we now wanted to call this function with a different directory, but keep $expires with its default value, we can now write this

    key: 'content-home',
    value: 'something bla bla',
    directory: 'someOtherDir/'

instead of that:

    'something bla bla',

Named arguments can also be used together with ordered arguments. That means that you could, for example, write this:

$post = new Post(
    'Some interesting post',
    body: 'Bla bla body text here',
    author: 'John'

What would not work, however, is doing it this way:

$post = new Post(
    title: 'Some interesting post',
    'Bla bla body text here',
    author: 'John'

You can only use ordered arguments together with named ones at the beginning of the argument list. If you're using ordered arguments between named ones, PHP throws an error.

Named arguments are also supported in annotations/attributes, by the way!

In case you want some more info on that, view this article and the RFC!

uBlock Origin: Re-enable allow rules

Wed 22, Jul 2020


So a few days ago I noticed how I can't set any allow rules in uBlock Origin anymore. Those were useful to me, because I have some custom filters, which sometimes block actually wanted content. Using the allow rules, I could simply temporarily override them.

Now with uBlock Origin 1.28.0, they have been removed from the UI. However, there is a workaround to (temporarily) re-enable them: press Ctrl twice in the popup. Now you can set allow rules again.

Notice that this is temporary, so when you open the popup the next time, you will have to do it again.

Put a README on your GitHub profile

Fri 10, Jul 2020


I discovered a really nice easter egg in GitHub today! If you create a repository that's named exactly like your GitHub username and put a in there, the rendered README will show up on your profile!

My profile with the README


  1. Create a new repository named as your GitHub username (if your name is Example, name the repository Example); GitHub shows you a green easter egg alert right under the name input if the name is correct
  2. Check that Initialize this repository with a README is on
  3. Click Create repository

Now edit the newly created with the contents you want to show on your GitHub profile.

Editing the

PHP 8 Attribute Syntax

Thu 02, Jul 2020

So @@ reaches the quota and has been elected as the final attribute syntax for PHP 8.

@@ will be the attribute syntax for PHP 8:

class Something {}

I personally think that choosing @@ was the right decision.

If you don't really know what's going on with those attributes, read this!


Blogs without feeds

Mon 01, Jun 2020

Just visited yet another interesting tech blog without a feed - no RSS, Atom, JSON.

I don't get why some people don't put a feed on their blogs; That way I could easily subscribe to it and read their upcoming posts. Now I would have to bookmark it and re-visit it every few days.

Pro tip: tag feeds on

Thu 14, May 2020

Just a quick pro tip for you: if you want to get the feed of only a specific tag of my blog, use the following URL scheme:{atom|rss|json}/{tag}/

Example: If you wanted to only see webdev-related posts in Atom format:

This feature has been around for quite some time now, but most people probably don't know it


My Git Mirror

Mon 11, May 2020

The Git mirror is no longer available. I'm looking forward to a new solution, though.

I just mirrored my GitHub repositories, just in case they go down, at offline. I'm using GitList for now.

Switching to a new UniFi controller

Tue 05, May 2020

My new CloudKey Gen2 Plus just arrived in the post today. Moving everything over with next-to-no downtime was very simple:

  1. Get a backup: Settings -> Backup -> Download file (you can adjust the timespan)
  2. Shut down the controller
  3. Open up the new controller
  4. Select Restore from backup in the setup and upload the backup file

That's it!

The UniFi AP-AC Lite

Mon 04, May 2020

I love the UniFi AP-AC Lites. They're awesome. Another one came in the post today and I was really hyped to set it up. They have an amazing reach and good speeds. Setting new ones up is as easy as plugging them into the network, opening up the UniFi network controller and integrating the new AP.

About 1 month ago I started with the UniFi system and it's really awesome - everything in one place. They not just have a really cool web dashboard, but a beautiful iOS app as well. Setting things up is really easy and extremely quick.

Edit: one thing that's really worth mentioning too: their packaging is nearly only made from paper! Really cool!

Add CSS to a page using HTTP headers

Tue 28, Apr 2020

Hey y'all,

I just read about the Link header at Impressive Webs. It works just like the <link> HTML tag. That means that you can use it to add stylesheets to a website! Below is a PHP-based demo:

The page:

header('Link: <styles.css>; rel=stylesheet');
echo '<p>Some text here. This will get displayed using a sans-serif font if your browser supports the Link header. If not, your browser\'s default font will be used.</p>';

The stylesheet (named styles.css):

body {
    font-family: sans-serif

The header will look like this:

Link: <styles.css>; rel=stylesheet

You can add multiple stylesheets by adding multiple Link headers, btw.

Browser support

Even though this is a standardized feature that has been around since HTML4, it seems to work in Firefox only. It is not deprecated, though. This is what the HTML4 spec says about it:

This section only applies to user agents conforming to versions of HTTP that define a Link header field. Note that HTTP 1.1 as defined by [RFC2616] does not include a Link header field (refer to section 19.6.3).

Why bother if it's only supported in Firefox?

I think it's just something really cool to look at. If you use it in a project, I'd highly recommend you to use <link> in addition, because otherwise most users probably won't see your stylesheets.

If you want to find out more about it, I'd highly recommend you to read this article at Impressive Webs and look at the Link header's MDN page.

You are on page 1 right now.

Back to top