Originals β posts I've written myself.
How to write exceptionally good exceptions in PHP original
In this video, which is part of the mailcoach video course, I show how I like to write my exceptions.
At the time of writing this post, we're running a contest where you can win a free mailcoach license.
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
No spam. Unsubscribe anytime. You can also follow me on X.
How to refactor complex if statements original
Have you every come across confusing if statements with complex conditionals such as this? I bet you did!
// please kill me π€―
if (!(($this->shipping_country == "GB" || (strcmp($this-status, "Valid") !== 0)) {
To me, this is completely unreadable.
In the video below I show how I deal with this situation. Spoiler: add some tests around it and break the conditionals apart.
This video is part of the Mailcoach video course. It contains many more videos on how to write clear code. You can use this coupon code to get a nice discount of $10.
YES-I-WANT-TO-WRITE-READABLE-CODE
Laravel Tail can now tail remote logs original
laravel-tail is one of my favourite packages. When installed in a Laravel app it can be used to tail the log file. To tail a log file locally, you just have to issue this command: php artisan tail and it'll start tailing the latest log file (so it works for both daily and single log files). Any lineβ¦
Using BetterTouchTool as a window manager original
In this short post, I'd like to share how I use BetterTouchTool in my daily work.
laravel-event-sourcing v3 has been released original
Our spatie/laravel-event-sourcing package is probably the best starting point for event sourcing in Laravel. It has excellent docs, that explain event sourcing from scratch, support for aggregates, projectors, and much more! It's all beautifully integrated in Laravel.
Recently we released v3 of the package. In this blogpost I'd like to walk you through the changes.
A PHP package to execute commands via SSH original
Our team released a new package called spatie/ssh. This package allows you to execute commands via an SSH connection.
Manage Docker containers using PHP original
Last week, my colleague Ruben and I released a package called spatie/docker, that makes it easy to spin up docker containers and execute commands on them. In this blog post, I'd like to introduce what you can do with it and why we built this.
Pragmatically testing multi-guard authentication in Laravel original
Last week our team launched Mailcoach, a self-hosted solution to send out email campaigns and newsletters. Rather than being the end, laughing something is the beginning of a journey. Users start encountering bugs and ask for features that weren't considered before.
One of those features requests we got, is the ability the set the guard to be used when checking if somebody is allowed to access the Mailcoach UI.
In this blog post, I'd like to show you how we implemented and tested this.
Building Mailcoach original
Today, our team released Mailcoach, a beautiful, self-hosted mailing list manager. It integrates with services like Amazon SES, Mailgun, or Sendgrid to send out mailings affordably. Itβs packaged as a stand-alone app, or can be integrated into a Laravel project, it's perfect for bloggers, artisans, and entrepreneurs.
Even if you're not in the market for an email solution, Mailcoach includes a video course on how itβs built. I'm sure you'll see some valuable techniques that you can bring to your own project.
In this blogpost, I'd like to share why and how we've built this.
Remove all history from a GitHub repository original
From time to time I need to remove all history from a GitHub repository, for instance right before releasing a package I've worked on in private. Sometimes I don't want people to see all mistakes I've made along the way :-).
Using GitHub actions to run the tests of Laravel projects and packages original
For many years we've relied on Travis to run the tests of our packages. For projects we used Circle CI. Recently we moved this responsibility from Travis and Circle CI to GitHub actions. In this blogpost I'd like to explain why and how we did this.
πΊ How to avoid large function signatures by using pending objects original
In this video I demonstrate how to you can create a fluent API by using pending objects. We'll take a look at how subscribers can be created in Mailcoach. As a bonus I explain how jobs are dispatched using a pending object in Laravel.
My favourite albums released in 2019 original
These are my 10 favourite albums which were released in 2019, alphabetically sorted.
πΊ Building filters using laravel-query-builder original
On the subscribers screens of the Mailcoach, you can filter out the subscribers that have a certain status, you can search and sort them.
In the video below, which is part of the upcoming Mailcoach video course, I explain how we built these filters, powered by three of our packages: laravel-query-builder, query-string and Blade X.
Building Mailcoach: deleting unconfirmed users automatically original
My team and I are currently building Mailcoach, a self-hosted solution to easily send out newsletters and email campaigns. In this video, I live code a new small feature.
This video was created unrehearsed and I didn't make any edits. So you can see every mistake that I made along the way.
A recap of 2019 original
A year ago, I wrote a recap of 2018. Now that 2019 is coming to a close, I thought it might be fun to write a similar post on what I did this year.
Automatically convert your code to PHP 7.4 syntax using Rector original
In PHP 7.4, two new features were introduced that I'd like to use in my packages and projects: short closures and typed properties. Even though an IDE can help with converting to the new syntax, I'd don't want to manually hunt down all the places where the new syntax can be used. Lucky there's a tool that can do this work automatically.
Streaming a large export as a CSV file to the browser original
A while ago, I created an easy to use framework agnostic PHP package to read and write CSV and Excel files called spatie/simple-excel. Behind the scenes, generators are used to ensure low memory usage, even when working with large files. Today I added a method that allows you to stream CSV files to the browser. In this small blog post, I'd like to demonstrate how you can use it.