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. This makes the codebase very fragile and any small change could break something if you aren’t careful. How do we test the untestable? AspectMock to the rescue!

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.

Somewhat recently, I was refactoring a project that was having issues uploading and importing large CSV files. I was running into all kinds of issues from timeout errors to memory allocation exceptions. The solution was to break up the import and upload it in chunks. This alone was pretty easy but I also wanted to include the ability to display the progress of the entire import. The problem was, I was using AJAX to upload the data.

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.

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. It would much easier if there was a package we could use instead. Lucky for us, there is!