Don't test constructors
Matthias Noback wrote down some good testing advice.
Read more [matthiasnoback.nl]
Posts tagged with best practices
Matthias Noback wrote down some good testing advice.
Read more [matthiasnoback.nl]
Regular expressions are powerful, PHP but they are not known to be readable, and more often than not, maintaining a regular expression is not a straight-forward task. Here are some tips to improve and write better regular expressions in PHP.
Read more [php.watch]
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.
"As a Laravel developer, this is the one newsletter I most look forward to. Freek has a talent for distilling packages or techniques down to something immediately useful - one tip can save you hours and even weeks. It's concise and practical and highly relevant."
– Edit
Mohamed shows how you can deal with N+1 problems using the $with model attribute and the newly added Model::preventLazyLoading() method.
– tideways.com – Edit
Benjamin Eberlei tells the story of a performance mistake that is quickly made even by experienced developers.
Read more [tideways.com]
by Freek Van der Herten – 1 minute read – Edit
by Freek Van der Herten – 1 minute read – Edit
Most developers have probably seen some complex conditionals in legacy code. In this video I show you how to refactor those.
– frontstuff.io – Edit
An excellent post on the subject by Sarah Dayan.
Read more [frontstuff.io]
by Freek Van der Herten – 1 minute read – Edit
You can make your code more readable by moving all your exception messages to dedicated classes. We using this technique in all our projects and packages.
by Freek Van der Herten – 2 minute read – Edit
Out of the box, Laravel comes with the ability to generate "signed" URLs. These URLs have a hash in their query string that verifies that the URL was not modified.
At Flare, we use these signed URLs to add action links in mail notifications. The action links allow users to snooze and resolve errors right from the mail without having to be logged in. Pretty convenient!
My buddy Dries Vints noticed a slight drawback. He got a mail from Flare that contains these action links. A few hours after the mail arrived, he clicked one of the action links. This is what he saw.
by Freek Van der Herten – 1 minute read – Edit
Some best practices and tips for composing high quality pull requests when contributing to open source projects.
Read more [dev.to]
Let's dive into some of the design considerations you might make when designing abstractions that reach over a network.
Read more [blog.frankdejonge.nl]
– buttondown.email – Edit
I do want to point out that print debugging has one critical feature that most step-based debuggers don't have: you can see program state from multiple time steps all at once.
Read more [buttondown.email]
– Edit
YouTube star Povilas Korop shares and discusses five rules from our guidelines.
Security precautions Composer already has, and what you can do to improve them further.
Read more [php.watch]
– overreacted.io – Edit
In this post, Dan Abramov shares two different techniques to optimize components without having to reach for memo().
Read more [overreacted.io]
This is how Seb decides when or when not to explicitly add types in TypeScript.
Read more [sebastiandedeyne.com]
by Freek Van der Herten – 3 minute read – Edit
In almost every Laravel package, there is a ServiceProvider class responsible for registering bindings package resources such as config files, views, migrations, ...
While preparing a workshop that I gave on package development, I watched some videos of our own Laravel package training video course again. While watching the videos on using the service provider again, I had the idea to simplify how resources can be registered.
Meanwhile, I've fleshed out the idea and release it as a new package called laravel-package-tools. In this blog post, I'd like to introduce the package to you.
– stitcher.io – Edit
My colleague Brent makes the case for targetting and uses the latest PHP version.
Read more [stitcher.io]
– medium.com – Edit
"When it feels safe to make changes to code, it’s not really legacy code any longer".
Read more [medium.com]