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

A magic memoization function

Original – by Freek Van der Herten – 4 minute read

Last friday Taylor Otwell tweeted an easy to use memoization function called once: Wanted a slick way to generalize class method memoization. Y'all don't even want to know how it works. ? ? pic.twitter.com/xRJAY1C14y— Taylor Otwell (@taylorotwell) November 4, 2016 Taylor was kind…

Read more

An opinionated tagging package for Laravel apps

Original – by Freek Van der Herten – 4 minute read

There are a lot of quality tagging packages out there. Most of them offer the same thing: creating tags, associating them with models and some functions to easily retrieve models with certain tags. But in our projects at Spatie we need more functionality. Last week we released our own - very…

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.

V2 of laravel-failed-job-monitor has been released

Original – by Freek Van der Herten – 1 minute read

In the beginning of the year we released a package to notify you when a queued job in your Laravel application fails. Today we tagged v2 of that laravel-failed-job-monitor package. The big change is that it now uses Laravel 5.3's native notification capabilities. So it's a cinch to modify the…

Read more

A class to parse, build and manipulate URLs

Original – by Freek Van der Herten – 2 minute read

For several projects and other packages we need to manipulate URL's. Instead of coding the same URL class over and over again, we extracted URL manipulation to it's own package. Here are some code examples on how you can use it. $url = Url::fromString('https://spatie.be/opensource'); echo…

Read more

Managing opening hours with PHP

Original – by Freek Van der Herten – 2 minute read

For several different clients we needed to display a schedule of opening hours on their websites. They also wanted to display if a department / store / ... is open on the moment you visit the site. My colleague Seb extracted all the functionality around opening hours to the newly released…

Read more

A Laravel package to store language lines in the database

Original – by Freek Van der Herten – 3 minute read

In a vanilla Laravel installation you can use language files to localize your app. The Laravel documentation refers to any string in a language file as a language line. You can fetch the value of any language line easily with Laravel's handy trans-function. trans('messages.welcome'); //…

Read more

Sending a welcome mail with Laravel 5.3

Original – by Freek Van der Herten – 7 minute read

Recently I was working an a project where, in order to use the webapp, users should first apply for an account. Potential users can fill in request form. After the request is approved by an admin they may use the app. Our client expected that the barrier to request an account should be very low.…

Read more

Laravel-fractal v2 has been released

Original – by Freek Van der Herten – 1 minute read

Last week v2 of laravel-fractal was released. This package is a developer friendly wrapper around the League's Fractal package. It a Laravel context it can be used to transform your Eloquent models to JSON output for an API. Think of it as toJson (or toArray) on steroids. This is how you can work…

Read more

Our packages have been downloaded one million times

Original – by Freek Van der Herten – 12 minute read

I'm very happy to announce that, as of today, our Laravel and PHP packages have been downloaded a million times. We now have more than 80 packages registered on Packagist. All combined they are downloaded around 150 000 times a month, and that number seems to be growing. Our GitHub organisation has…

Read more

A little library to deal with color conversions

Original – by Freek Van der Herten – 1 minute read

My colleague Seb needed to convert some color values in PHP. He looked around for some good packages, but there weren't any that fit the bill. So guess what he did? He just created a new package called spatie/color. Here's what it can do: $rgb = Rgb::fromString('rgb(55,155,255)'); echo…

Read more

Simplifying presenters in Laravel

Original – by Freek Van der Herten – 3 minute read

In the Laravel template that we use to kickstart all our client projects at Spatie, I recently changed the way we handle presenters. Instead of using Jeffrey Way's popular presenter package we now use simple traits. In this post I want to give some background on that change. In case you've never…

Read more

Taking care of backups with Laravel

Original – by Freek Van der Herten – 8 minute read

A new major version of laravel-backup was recently tagged. This package can backup files and databases of your Laravel app (or any PHP application really). The backup consists of a zipfile containing a dump of the databases and all files that are selected for backup. The package will copy over the…

Read more

Our dashboard has been updated to make use of Laravel Echo

Original – by Freek Van der Herten – 1 minute read

A couple of months ago we released a dashboard powered by Laravel, Pusher and Vue.js. In tandem with Laravel 5.3 a new JavaScript library was released called Laravel Echo. This library makes it very easy to work with a service like Pusher. This weekend I took the time to update the dashboard to make…

Read more

Automatically generate a sitemap in Laravel

Original – by Freek Van der Herten – 7 minute read

Today my company released a package called laravel-sitemap. There are already a lot of excellent sitemap packages out there. They all have in common that you have to manually add links that must appear in the sitemap. With our new package that isn't required. It can automatically build up a sitemap…

Read more

Debugging collection chains

Original – by Freek Van der Herten – 2 minute read

A couple of weeks ago I published a blog post on how you can easily debug collections using a dd macro. Meanwhile my company released a package that contains that macro. In this post I'd like to introduce a new dump macro, recently introduced in the package, that makes debugging collection chain…

Read more

A package to easily work with regex in PHP

Original – by Freek Van der Herten – 2 minute read

PHP offers some functions to work with regular expressions, most notably preg_match, preg_match_all and preg_replace. Unfortunately those functions are a bit hard to use. Take preg_match_all for example, it requires you to pass in an array by reference to get all the matches. When something goes…

Read more

Some handy collection macros

Original – by Freek Van der Herten – 4 minute read

Laravel's collection class is truly wonderful. It contains a lot of handy methods and you can create some very elegant code with it. In client projects I found myself adding the same macro's over and over again. That's why my colleague Seb and I took some time to create a package aptly called…

Read more

Things I learned from reading Laravel: Up and running

Original – by Freek Van der Herten – 3 minute read

Matt Stauffer is currently putting the final touches on his new book called Laravel: Up And Running. It aims to be a good guide for newcomers to the framework. But even if you've got some experience with Laravel, it should be worth your time to read it. Even Matt himself picked up a lot of cool…

Read more