In this section you can read posts I've written myself.

A short introduction to laravel-event-projector

Original – by Freek Van der Herten – 1 minute read

The last few months I've been working on a package called laravel-event-projector. This package aims to be a simple and very pragmatic way to get started with event sourcing in Laravel. Ahead of it's release, which will happen in a few days, I've recorded a small video introduction. You can find the…

Read more

Stay up to date with all things Laravel, PHP, and JavaScript.

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Breaking Laravel's firstOrCreate using race conditions

Original – by Freek Van der Herten – 4 minute read

Recently I was working on a client project where a data import was performed via queues. Each record was imported in its own queued job using multiple queue workers. After the data import was done we had more rows than expected in the database. In this blogpost I'd like to explain why that happened.…

Read more

The open source department at Spatie is doing overtime

Original – by Freek Van der Herten – 3 minute read

Bad title because we don't do overtime at Spatie, but our team has been very busy putting out new open source stuff. In the past weeks our team has released three new packages. In this post I'd like to quickly introduce them too you. sheets First up is spatie/sheets, created by Sebastian. This…

Read more

A package that makes event sourcing in Laravel a breeze ?

Original – by Freek Van der Herten – 11 minute read

In most applications you store the state of the application in the database. If something needs to be changed you simply update values in a table. When using event sourcing you'll take a different approach. All changes to application state are stored as a series of events. The key benefit here is…

Read more

When empty is not empty

Original – by Freek Van der Herten – 2 minute read

Recently when I was working on a project I got some strange results when using the empty function. Here's what I was debugging. I've simplified the code a bit to share with you. var_dump( $person->firstName, empty($person->firstName) ); This was the result: string(5) "Freek"…

Read more

Automatically close stale issues and pull requests

Original – by Freek Van der Herten – 5 minute read

At Spatie we have over 180 public repositories. Some of our packages have become quite popular. We're very grateful that many of our users open up issues and PRs to ask questions, notify us of problems and try to solve those problems, ... Most of these issues and PRs are handled by our team. But…

Read more

Doing less

Original – by Freek Van der Herten – 6 minute read

Last week I stumbled upon this article titled "GitLabbers share how to recognize burnout". It list these points to recognize burnout: You're constantly tired You no longer enjoy things Your job performance suffers Your relationships are strained (You have a hard time remembering…

Read more

laravel-medialibrary v7 has been released ?

Original – by Freek Van der Herten – 14 minute read

laravel-medialibrary is a powerful package that can help handle media in a Laravel application. It can organise your files across multiple filesystems, generate thumbnails, optimize images and much much more. At Spatie we use this package in nearly every project. The last few months our team has…

Read more

Today we hit 10 million PHP package downloads

Original – by Freek Van der Herten – 2 minute read

For the past few years Spatie, the company where I work, has released many Laravel and PHP packages. Those packages are primarily built to be used in our own projects. We do not operate in a void. We have a community around us. They use our work. They help to make our packages better by submitting…

Read more

Using Content Security Policy headers in a Laravel app

Original – by Freek Van der Herten – 5 minute read

By default all scripts on a webpage are allowed to send and fetch data from and to any site they want. If you think about it, that's kinda scary. Imagine that one of your JavaScript dependencies would send all keystrokes, including passwords, to a third party website. That would be pretty bad. In…

Read more

A package to assign statuses to Eloquent models

Original – by Freek Van der Herten – 2 minute read

Imagine you want to have an Eloquent model hold a status. It's easily solved by just adding a status field to that model and be done with it. But in case you need a history of status changes or need to store some extra info on why a status changed, only adding a single field won't cut it. To handle…

Read more

How to upgrade from PHP 7.1 to 7.2 on MacOS using Homebrew

Original – by Freek Van der Herten – 1 minute read

PHP 7.2 was released almost two months ago. I decided to wait a bit until a stable version of Xdebug with PHP 7.2 compatiblity was available. And that happened yesterday with the release of Xdebug 2.6. I'm on MacOS and use brew to install stuff. Upgrading from PHP 7.1 to 7.2 is laughably easy. These…

Read more

How to send a "trial expiring soon" mail in Laravel Spark

Original – by Freek Van der Herten – 6 minute read

I'm currently building a webapp named Oh Dear: an easy to use and beautiful website monitor. It has recently gone into it's beta phase. At the moment of writing everybody can register a new account. After you've registered you'll start your trial period of 10 days. Oh Dear is built on top Laravel…

Read more

Handling CORS in a Laravel application

Original – by Freek Van der Herten – 5 minute read

Recently we released laravel-cors. This package can add the necessary CORS headers of your Laravel app. In this post I'd like to give a quick explanation of what CORS is and how you can use the package. What is CORS Imagine that all JavaScript code for domain X running in a browser would be able to…

Read more

The story behind our open source efforts

Original – by Freek Van der Herten – 15 minute read

This post was first published on 24daysindecember.net Chances are that you've never heard of my company Spatie. We specialise in creating Laravel applications for our clients. Our team is rather small: we consist of only 6 developers and one manager. On first glance we are just a web agency like…

Read more

An async map function

Original – by Freek Van der Herten – 3 minute read

Laravel has an excellent Collection class that has many useful operations. The class is also macroable. This means that you can add function to it at runtime by calling macro on it and passing a name and a closure. In our projects we tend to code up the same macro's over and over again. That's why…

Read more

Laravel-medialibrary v7 preview: media collections

Original – by Freek Van der Herten – 5 minute read

laravel-medialibrary is a package that can help handle media in a Laravel application. It can organise your files across multiple filesystems, generate thumbnails, optimize images and much much more. Like mentioned before on this blog my team and I are currently creating a new major version, v7,…

Read more