Implementing event sourcing: aggregates original
Recently we've released v2 of laravel-event-projector. The package is probably the easiest way to get started with event sourcing in Laravel.
One of the prominent new features is support for aggregates. While creating v2, I found it surprising that such a powerful concept could be implemented in so little code. In this short blog post, I'd like to explain how aggregates are coded up.
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.
No spam. Unsubscribe anytime. You can also follow me on X.
"Always fresh, useful tips and articles. Carefully selected community content. My favorite newsletter, which I look forward to every time."
When to use Gate::after in Laravel original
In a Laravel app policies are a great way to organize authorization logic that revolves around models.
For the longest time, I've been using Gate::before to allow superadmins to do anything they want. While working on a new app, it finally clicked how Gate::after can be useful too. I'd like to share that knowledge in this blog post.
Simplifying controllers original
In this blog post, I'd like to highlight two tips to make controllers in Laravel feel much lighter.
Find Segfaults in PHP like a boss
Grégoire Pineau explains how you can find the source of a segfault in PHP.
Sometimes, a segfault happens, but you don’t know where, and your PHP installation does not have tools to find it. Or sometime, you think PHP is hanging, but you don’t know where. You may use xdebug, but you don’t want to click so many times on the « next call » button.
Read more [jolicode.com]
Access related data in Eloquent using an IDE friendly way
?? Laravel Core Adventures - Did you know?
— Christoph Rumpel ? (@christophrumpel) April 17, 2019
In Laravel, we can access related data as if we would call a class property. But in fact, this is just a shortcut/hack for using the relationship method we have defined.
The second approach has one advantage, your IDE can follow it. pic.twitter.com/OjL4zNqUnp
Read more [twitter.com]
The right way to call assertions in PHPUnit
It's a bit of a click baity title, but reading it I learning that all PHPUnit's asserts have a function equivalent.
During the preparation of TDD workshops, I began to think about how to write assertions. It turns out that there are several possibilities, but is there the only correct one?
Read more [arkadiuszkondas.com]
Slack Is Not Where 'Deep Work' Happens
Personally, when I want to work on something I just turn off all notification on my Mac.
Probably reached for the phone. Turned off the alarm. Glanced at the time. Scrolled through the Slack notifications. Went through the emails. You will likely continue doing it throughout the day, approximately 2,617 more times, according to some studies. We all do it, and despite all the virtues of digital minimalism, completely giving up those habits is extreme and, arguably, unnecessary. Yet we live in a culture obsessed with productivity and these harmless distractions are wreaking havoc on it.
Read more [blog.nuclino.com]
Unsafe SQL functions in Laravel
My colleague Brent offers some more details on the intricacies of Laravel's query builder.
I recently learned that not all query builder functionality in Laravel is "safe". This means that user input shouldn't be passed directly to it, as it might expose your application to SQL injection vulnerabilities.
Read more [stitcher.io]
An important security release for laravel-query-builder original
Our laravel-query-builder package exposed a serious security issue: it allowed SQL injection attacks. Laravel Query Builder v1.17.1, which is now available, fixes the vulnerability. If you're using the package, stop reading now and upgrade to the latest version first. For Laravel 5.6, 5.7 and 5.8…
Don’t forget to be selfish every now and then
A short and sweet article by my colleague Seb.
I was always adding features because I’d expect other people to expect them. It’s a trap! You’re not making people happier by guessing what they might need. You’re not doing anyone a disservice by building things for yourself.
Read more [sebastiandedeyne.com]
Using Oh Dear! to keep your Varnish cache warm
On the Oh Dear! blog, Mattias Geniar explains how you can use our service to keep your Varnish cache warm.
Slow websites are annoying, right? We sure think so. One common solution is to introduce a caching proxy like Varnish to help cache pages and reduce your server load. The good news is, if you have Oh Dear!, you can let those 2 work together.
Read more [ohdear.app]
Laravel event projector v2 has been released original
Laravel event projector is a package that aims to be the entry point for event sourcing in Laravel. It can help you setting up aggregates, projectors and reactors. Earlier today our team released v2. This version streamlines the projectors and reactors from v1 and adds support for aggregates.
In this blogpost I'd like to explain a potential problem with traditionally built applications. After that we'll take a look at what projectors and aggregates are. Finally we'll walk through an example how you can create an aggregate laravel-event-projector.
Isset can accept multiple variables
It's a minor thing but PHP's `isset` can accept multiple vars which will allow you to simplify your code. ? pic.twitter.com/GBgYEDSOya
— Eric L. Barnes (@ericlbarnes) April 4, 2019
Read more [twitter.com]
The end of Extended Validation certificates
Mattias Geniar argues that you shouldn't buy extended validation certificates.
You know those certificates you paid 5x more for than a normal one? The ones that are supposed to give you a green address bar with your company name imprinted on it? It's been mentioned before, but my take is the same: they're dead.
Read more [ma.ttias.be]
Keep your assets Prettier on every commit
Sebastian wrote a short post on how to configure Husky to run Prettier on every commit.
I'm a happy prettier user to keep my CSS and JavaScript files consistent. However, it's hard to keep the discipline to run Prettier before every commit. This week I decided to automate the process with Husky and lint-staged.
Read more [sebastiandedeyne.com]
20 unknown gems of Laravel
KH. Jebran Ali lists a few cool Laravel tricks
Laravel is full of hidden gems that I have discovered during working on different tasks. Some of these gems were less-known or un-documented features, functions parameters and hacks. In this blog post I will share those hidden gems with you, let’s get started.
Read more [meramustaqbil.com]
Super simple start to serverless
Kent C. Dodds guides us through creating our first function on Netlify.
Luckily for us, almost exactly one year ago from the time I'm writing this, Netlify took the complexity of AWS Lambda functions and made it super simple.
Read more [kentcdodds.com]
The PHP UK videos have been released
PHP UK is one of my favourite conferences. Unfortunately I couldn't make it this year, but I'll be sure to watch the videos that have been published a little while ago.
Here's a cool session on running PHP on AWS Lamba by Neal Brooks
You can watch all other talks in this playlist on YouTube.
Name it, and they will come
React lead dev Dan Abramov makes the case for naming your ideas and projects.
The problem it’s solving might be so ingrained that we don’t even notice it. It’s the elephant in the room. And we can’t discuss what we never named.
Read more [overreacted.io]