...about refactoring, testing, best practices, and stuff.
Upgrading to Laravel 10, PHPUnit 10, and Pest 2
We're upgrading from Laravel 9 to 10, and PHPUnit 9 to 10, and, if all goes well, we'll top it off by migrating to Pest,...
Speed up GitHub Actions by caching Composer, Rector, & Pint
GitHub's 2000 minutes per month of free usage of GitHub Actions is usually enough to handle light workflows. However, as...
Doing stricter checks in PHP
A nice refactoring I've learned recently is to utilize types in conditionals. For years I’ve been doing if (!empty($post...
Upgrading to Eloquent accessors & mutators from Laravel 9
Laravel 10 is making the headlines these days. However, many apps are stuck in older versions, or at least still use the...
Development Driven Testing
One of the first roles that I've been working on since I went full-time remote was that of the unit tester. I wasn't use...
Allowing users to send emails with their own SMTP settings in Laravel 9
Various guides exist on how to do this in Laravel, but all the ones I found (this and this) worked only up to Laravel 8....
Safely upgrade from PHP 7.4 to 8.1 using Rector
I have to say it from the start, the only thing that comes close to safely upgrading a codebase is having a solid set of...
Refactoring #8: What is dead may never run
It's important to take a good look at your code and clean up when you're done with it. Once in a while, we tend to forge...
Refactoring #7: Upping the coding style game in PHP using Rector
Continuing from the last post, we're now exploring other Rector configurations that help us improve our code. It's funny...
Refactoring #6: Improve Code Quality in Laravel using Rector
I recently discovered Rector and was completely blown away by its power and effectiveness. The promise is simple: you in...
Adding user-specific settings in Laravel
There are many ways to handle this, but the best solution in our case was to use a JSON settings column in our User model.
Refactoring #5: From arrays to Data Transfer Objects
The problem is simple: our class is returning an array of key-value pairs, and this array is used in quite a few other places in code.
Generate monthly chart data with Eloquent & Carbon
We want to display the number of users that signed up for each month. How do we account for months that have no data? How performant can it get?
Testingmania #4: Testing Form Requests with PHPUnit
PHPUnit allows us to DRY up our tests with Data Providers, which are methods that allow you to execute a single test multiple times, with different input.
Refactoring #4: Using Minio to work with S3 buckets locally
Code should behave the same across all development environments. We're using Minio to unify the experience.
Refactoring #3: Optimizing Eloquent queries & console commands
We're refactoring a heavy command in terms of memory consumption, database strain, and execution time, in hopes of having it run daily.
Refactoring #2: From controllers to actions
We're extracting some pieces of functionality into their own classes. Their goal is simple: to do one thing, and one thing only.
How to add support for HEIC images with ImageMagick in PHP
Apple released a new image format called HEIC/HEIF, and it broke many apps that handle image processing. The PHP library...
Refactoring #1: Using ternary and null coalescing operators in PHP
Unnecessary long syntax, endless chaining of if conditions, and a redundant nested code. Let's see how it can be improved.
Testingmania #3: Testing Fat Laravel Controllers - Pt. 2
Going further we're testing if unauthenticated users can upload photos, whether they're allowed to upload files other than images, whether the images get uploaded to an S3 bucket, and more.
Testingmania #2: Testing Fat Laravel Controllers - Pt. 1
Many new products launching out there don't embrace a TDD approach. It's the norm that code is pushed to production for months until the MVP is ready or launch is due. That's when the Project Managers decide, it is time, for testing.
Testingmania #1: Unit Testing Laravel Models
Some might consider Laravel model testing to be a gruesome task, especially when there's plenty of them in the codebase, and most of them are covered by other unit or feature tests. However, to get to that sweet 100% (or so) coverage, these tests need to be carried out.
How to make a typewriter animation using Vanilla JS and Highlight.js
You’ve seen typewriter animations. You’ve seen the power of Highlight.js. Now you’re seeing the ultimate game-changer: typewriter animations for highlighted code, yay.