Some of us have had the pleasure of working with someone else’s ancient codebase to either add new features or fix bugs. It’s never fun and usually a pain. Because of the design (or lack thereof) of the application, it doesn’t lend itself to unit testing. The code is littered with static method calls, objects instantiated inside methods rather than being injected through a constructor, and other elements of poor design.…
Read more »Laravel 5 and above icludes a cool feature to help simplify configuration and deployment to different environments. Before you had to create separate directories within ‘app/config’ to separate configuration based on the environment. You would then use varying methods to tell Laravel which environment it was in a bootstrap file. This can get pretty messy real quick epecially if you are adding third party libraries that may require some special configuration options.…
Read more »I’ve been looking for a way to challenge myself as well as showcase some of my knowledge to the world. After some thinking, I’ve decided that I would go ahead and write a book. I’ve been reading a lot about aspect-oriented programming and really like what it provides to enhance object-oriented programming. There isn’t a lot of information about this in the PHP community so I figured a book would be a great way to drum up some more interest and help create a larger community around the subject of AOP.…
Read more »In my last article we took a look at using aspect oriented programming (AOP) in PHP by installing the excellent AOP PECL extension for PHP. This is great if you have admin access to the servers you run your code on. It’s very common though, for people to run their code on shared hosting. These types of providers don’t usually provide a way for you to install any extra PHP extensions besides the common extensions they provide.…
Read more »There are many ways to modify the behavior of existing code with actually changing the core logic. Some patterns you might be familiar with are the decorator pattern or the observer pattern. Both allow you to take another object and modify the behavior by wrapping your modifcations around the original code. One pattern you might not be familiar with though, is the interceptor pattern. The interceptor pattern is a core concept of what is called aspect oriented programming (AOP).…
Read more »