Modelling Data and Behaviour in PHP
Move beyond anonymous arrays with DTOs, value objects, enums, immutability, and explicit state transitions. Some examples use Laravel.
6 articles published
Start readingReading order
Articles in this series
Follow the order below, or choose the article you need.
-
01
Avoid the AOP: Array-Oriented Programming
Arrays are a convenient way of organizing and passing data in PHP applications, but should we do it? In this article, I'll show the cons of abusing the use of associative arrays and a simple alternative for that.
Sep 26, 2023 · 8 minutes
-
02
Data Transfer Objects in Laravel - Why and How
Data Transfer Objects can be a great way to improve your applications. Let's learn why and how to use them in Laravel.
Dec 16, 2022 · 4 minutes
-
03
Understanding Value Objects in PHP
Value Objects is a fantastic concept that we can use to improve our applications. They are small objects, such as Money, DateRange, Email, or Age, that we utilize on complex applications. They are key elements in creating efficient, understandable, and maintainable code.
Oct 6, 2023 · 8 minutes
-
04
Strategic Enums in PHP
Enumerations, commonly known as Enums are a powerful tool in Software Development and can play an important role in the Architecture and Design of applications if used correctly. In this article let's review how we can strategically use them to improve our applications.
May 16, 2024 · 5 minutes
-
05
Immutability in PHP Beyond readonly
A deep dive into immutability in PHP, from readonly properties and interior mutability to immutable value objects, collections, dates, cloning, boundaries, and testing.
Aug 14, 2026 · 14 minutes
-
06
Welcome to the State Machine Pattern
Learn what the State Machine Pattern is and how to apply it in your PHP applications with this in-depth article about it
Aug 28, 2025 · 15 minutes