Mirror, Mirror on the Wall: Building a New PHP Reflection Library
Reflection is commonplace in many modern programming languages and allows analysis of code structure and more. What if we could do more? Better Reflection is a library that goes further than the simple reflection we’re used to in PHP. I’ll explore how the library works, some of the difficulties we faced, and how you can leverage this new power today. by James Titcumb
Strangler Pattern, Part 4: Unit Test Design with Mockery
Read this FREE article
When your PHP code must work through other classes, functions, APIs, and databases, those dependencies become a formidable challenge to writing your unit tests. In this article, we introduce Mockery, a drop-in replacement for PHPUnit’s built-in mocking library. We introduce and demonstrate strategies to use in keeping your unit test development sane. We cover spies, mocks, and expectations by Edward Barnard
Writing Better Code with Four Patterns
A design pattern is a repeatable solution to common problems we face in programming. Almost every industry has something similar: soldiers have tactics and strategies; firefighters have training manuals; pilots have scads of books (and access to flight simulators); builders have blueprints and we—software engineers—have design patterns. In this article, we will be covering four design patterns: dependency injection, factory method, strategy, and chain of responsibility. by Joseph Maxwell
Capturing an API’s Behavior With Behat
Imagine this—you’ve just joined a fairly well-established company that does millions of dollars in revenue every year. They’ve built things in a modular and scaleable way with microservices, always using the right tool for the job. There’s a mix of half a dozen different languages across the platform, and you can’t wait to get stuck in and start contributing.
What if you don’t have any tests to tell you about any possible side effects, though? You don’t know what the code is supposed to do, only what it currently does. As it turns out, that’s a great starting point. You write tests documenting what the service currently does. by Michael Heap
Education Station: Monkey Patching Your Way to Testing Nirvana
Ever found PHP’s built-in functions lacking? Ever concluded they didn’t quite do what you wanted them to do? Needed them to operate just a little differently? Have you wondered what your application might do if you could change what these functions returned? Then welcome to Monkey Patching. In this month’s edition of Education Station, we’re going to see how to apply monkey patching in your testing efforts. by Matthew Setter
Leveling Up: Understanding Objects
We understand how our programs work. As developers who are improving and making the transition from junior to mid-level and to senior and beyond, our understanding increases as we learn the ins and outs of the language, the application and the techniques that work to build successful applications. Over the next few months, we’ll be building up a solid foundation of Object-oriented concepts and patterns, how they work, and how Object-oriented code can be used to build more maintainable software. by David Stockton
Community Corner: Uncle Cal’s Thank You Letter
As we start out the new year, I did what I do every year at this time, reflect back. One of the things that came to mind this year—I’m not sure why—is a letter I wrote for roughly 40 people back in 2010. I meant for a letter of this sort to be an annual tradition, but sadly, life intervened. by Cal Evans
Security Corner: New Year’s Security Resolutions
Another year is in the bag, and the state of security in PHP is at an all time high. Sure, there’s still plenty of poorly written and unsecured code out there. However, there were several new advancements, in both the language and its ecosystem making it easier than ever to secure your applications. by Chris Cornutt
On Being a Polyglot
Why would I, in a magazine dedicated to PHP, be discussing the virtues of being a polyglot? In computer science terms of course. There is a great benefit to be found in exposing yourself to different programming languages and the concepts that they hold. They make you a better programmer overall as you expand your knowledge. by Eli White