Adding React to a legacy project
The project I’m currently working on is a textbook example of what happens when a project uses jQuery when it really ought to use a proper Javascript framework, or it starts out just using jQuery and...
View ArticleSimplify your tests with anonymous classes
Anonymous classes were added in PHP7, but so far I haven’t made all that much use of them. However, recently I’ve been working on building a simple dependency injection container for learning purposes....
View ArticleDecorating service classes
I’ve written before about using decorators to extend the functionality of existing classes, in the context of the repository pattern when working with Eloquent. However, the same practice is applicable...
View ArticleImproving search in Vim and Neovim with FZF and Ripgrep
A while back I was asked to make some changes to a legacy project that was still using Subversion. This was troublesome because my usual method of searching in files is to use Tim Pope’s Fugitive Vim...
View ArticleWhy bad code is bad
This may sound a little trite, but why is it bad to write bad code? Suppose you’re a client, or a line manager for a team of developers. You work with developers regularly, but when they say that a...
View ArticleYou don't need that module package
Lately I’ve seen a number of Laravel packages being posted on places like Reddit that offer ways to make your project more modular by letting you break their classes out of the usual structure and...
View ArticleWriting a custom sniff for PHP CodeSniffer
I’ve recently come around to the idea that in PHP all classes should be final by default, and have started doing so as a matter of course. However, when you start doing something like this it’s easy to...
View ArticleUnderstanding query objects
The project I’ve been maintaining for the last year has inherited a rather dubious database structure that would currently be very difficult to refactor, which also makes many queries more convoluted...
View ArticleCreating your own dependency injection container in PHP
Dependency injection can be a difficult concept to understand in the early stages. Even when you’re using it all the time, it can often seem like magic. However, it’s really not all that complicated...
View ArticleHigher-order components in React
In the last few weeks I’ve been working on a big rebuild of the homepage of the legacy application I maintain. As I’ve been slowly transitioning it to use React on the front end, I used that, and it’s...
View ArticleSearching content with Fuse.js
Search is a problem I’m currently taking a big interest in. The legacy project I maintain has an utterly abominable search facility, one that I’m eager to replace with something like Elasticsearch. But...
View ArticleHow much difference does adding an index to a database table make?
For the last few weeks, I’ve been kept busy at work building out a new homepage for the legacy intranet system I maintain. The new homepage is built virtually from scratch with React, and has a...
View ArticleWriting golden master tests for Laravel applications
Last year I wrote a post illustrating how to write golden master tests for PHP applications in general. This approach works, but has a number of issues: Because it uses a headless browser such as...
View ArticlePowering up git bisect with the run command
The bisect command in Git can be very useful when trying to catch any regressions. If you know that a bug was not present at some point in the past, and now is, you can often use bisect to track it...
View ArticleSkipping environment specific PHPUnit tests
If you’re doing client work, you don’t generally have to worry too much about working with any services other than those that will be installed in your production environment. For instance, if you’re...
View ArticleSetting private properties in tests
Sometimes when writing a test, you come across a situation where you need to set a private field that’s not accessible through any existing route. For instance, I’ve been working with Doctrine a bit...
View ArticleUsing Mix versioning outside Laravel
Laravel Mix is a really convenient front end scaffold, and not just in the context of a Laravel application. Last year, I added it to a legacy application I maintain, with positive results, and I’m...
View ArticleStoring Wordpress configuration in environment variables
Wordpress configuration can be a serious pain in the proverbial. Hard-coding configuration details in a PHP file is not a terribly safe way of storing the details for your database, as if the server is...
View ArticleFlexible data types with the JSON field
Relational databases have many advantages over other data stores. They’re (mostly) solid, mature products, they have the means to prevent data duplication while still allowing related data to be...
View ArticleInput components with the useState and useEffect hooks in React
Like many developers who use React.js, I’ve been eager to explore the Hooks API in the last year or so. They allow for easier ways to share functionality between components, and can allow for a more...
View Article