In software and web development, it’s always important to write code that is maintainable and extendable. The solution that you first create will likely change over time. So, you need to make sure you write your code in a way that doesn’t require a whole rewrite or refactor in the future.

The bridge pattern can be used to improve the extendability of your code and also improve the maintainability over time.

Intended Audience

This post is written for Laravel developers who have an understanding of how interfaces work and how to use them to decouple your code. …


In programming, it’s important to make sure that your code is readable, maintainable, extendable and easily testable. One of the ways that we can improve all of these factors in our code is by using interfaces.

Intended Audience

This article is aimed at developers who have a basic understanding of OOP (object oriented programming) concepts and using inheritance in PHP. If you know how to use inheritance in your PHP code, this article should hopefully be understandable.

What Are Interfaces?

In basic terms, interfaces are just descriptions of what a class should do. …


During my Christmas holidays at the end of 2019, I spent a bit of my free time building a Laravel package called Laravel Exchange Rates. The package is pretty simple and is just a wrapper for the API, with some caching features added for performance. At the time of writing this post, the package has around 43,000 downloads and has started getting around 4,000 downloads per month. It’s not that big in comparison to some other projects, but I’d like to think that I did something right for it to be getting that many downloads.

My main reason for…

How to Force Eager Loading and Prevent N+1 Issues in Laravel


In a past article, I talked about the performance improvements that you can achieve by using “eager loading” in your Laravel database queries. For anyone who hasn’t read it, click here if you want to give it a quick read.

What is Eager Loading?

When you are fetching any models from the database and then doing any type of processing on the model’s relations, it’s important that you use eager loading. Eager loading is super simple using Laravel and basically prevents you from encountering the N+1 problem with your data. This problem is caused by making N+1 queries to the database, where N is…


There may be times when you are working with arrays in your PHP code and need to switch the order of two items. If you’re using an array that uses integers as keys, this can be a pretty straightforward task. However, if you’re trying to swap two items of an associative array, this can be little bit more hands-on. So, in this short post, I’ll show you how you can use macros in Laravel to keep your code looking clean and reusable.

By the end of the post, you should have a brief idea on how to create a macro…


Testing is an integral part to web and software development. It helps to give you the confidence that any code that you have written meets acceptance criteria and also reduces the chances of your code having bugs. In fact, TDD (test driven development), a popular development approach, actually focuses around tests being written before any code is added to the actual app code base.

Intended Audience

This article is aimed at developers who are fairly new to the Laravel world but have a basic understanding of tests. This article won’t cover how to write basic tests (that’s for another post in the…

How to Validate Email Addresses using Laravel Mailbox Layer


Data integrity and validation are important aspects of web development and data collection. It’s always important that we (as web developers) validate data before we store in the database. As an example, imagine that you’re building a form for a new website that visitors can use to subscribe to your new email newsletter. I’m sure that you’d want to make sure that anyone submitting the form was using a valid email address and not trying to add any spam addresses.

Sure, there are things that you could do to verify that email, such as sending out a confirmation email for…


No matter if you’re brand new to Laravel or have been using it for years, there’s always something new to learn. The framework and its ecosystem are constantly evolving and growing to improve the overall developer experience. So, it can be quite important to keep up to date with the latest changes so that you don’t fall behind.

It’s also likely that you’ve run into a coding problem once or twice and needed to reach out to people online for a bit of advice and help. Let’s be honest, as developers we spend quite a lot of time searching online…


It’s estimated that 40% of people will leave a website if it takes longer than 3 seconds to load! So, it’s incredibly important from a business standpoint to make sure that you stay under that 3 second threshold.

Therefore, whenever I write any code for my new Laravel projects, I try to make sure to optimise the code as much as I can within my given time and cost constraints. If I ever work on any existing projects, I also try to use these techniques to update any slow running code to improve the overall experience for the users.


Should I use WordPress for My Website? — Ash Allen Design


WordPress is a platform and CMS (content management system) that you can use to build and manage your website. It’s actually used to power a large number of websites around the world. In fact, you probably visit quite a few WordPress websites on a daily basis without realising. It flaunts that it’s the “world’s most popular website builder” and powers 38% of websites. Those are some seriously impressive numbers!

Ash Allen

I’m a Laravel web developer based in the UK. I specialise in building websites and systems for small businesses to help them grow and increase their sales.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store