...about refactoring, testing, best practices, and stuff.
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
We're adding server support for HEIC images by executing ImageMagick shell scripts. This way, we're bypassing the GD or Imagick libraries.
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.