In a traditional approach, the consumer of a model must check for nulls and handle the condition gracefully when valid data cannot be returned, but this generates an explosion of conditionals throughout your code. Fortunately this tangled situation can be sorted out simply by creating a polymorphic implementation of the domain object using a design pattern called Null Object. Learn more about the benefits of Null Object with this article.
Those working in a Windows environment are more likely to download and install PHP from precompiled packages rather than compile from source. Compiling can be a frustrating task, especially on Windows! But hopefully this article will be your first step in overcoming many of the obstacles. Learn how to ensure your build environment is set up correctly, compile PHP, and both static and dynamic PHP extensions.
The Composite and Decorator patterns are among the most overlooked paradigms in PHP, but can provide for more flexible view objects. this is the second in a two-part series discussing the patterns, this time focusing on the Decorator pattern.
Patience is a virtue, but it’s generally not one inherent to today’s society when it comes to waiting for web pages to load. Slow loading pages can significantly impact conversions and even SEO. Knowing how to locate issues affecting performance through profiling is a good skill to have, and so this article will show you how to start profiling your PHP scripts using XHProf.
Ever since MVC started making inroads in the PHP community, the acronym’s “V” has been unfairly reduced to the level of a plain template whose responsibility was limited to rendering a few HTML pages, but views not only can be full-fledged objects carrying state, but also observers of a model, flexible enough to accommodate and react accordingly to fluctuations whenever the model’s state changes. In this two-part tutorial you’ll see how you can implement from scratch a couple of customizable view handling modules by sinking our teeth into the goodies of the Composite and Decorator patterns. In this part we’ll focus on the Composite pattern.
In this two-part series we explore a couple of customizable front controllers from a pragmatic standpoint. Continue the journey and see how easy it is to deploy a small, yet extensible, HTTP framework capable of putting to work a front controller along with the ones of a standalone router and a dispatcher.
The primary role of a front controller in web-based applications is to encapsulate the typical request/route/dispatch/response cycles inside the boundaries of an easily-consumable API. Tunneling all requests through a single entry point is an efficient way to implement a command-based mechanism, which not only allows you to route commands to appropriate handlers, but also exposes a flexible structure that can be scaled without much burden. This is the first in a two-part series exploring some straightforward approaches to implementing an expandable front controller from scratch.
Learn how to create a RESTful web service using Slim, a PHP micro-framework inspired by the Ruby framework Sinatra. It’s very simple, and is easy to understand and use. Slim is well-suited for creating simple RESTful web services and comes with some minimal components like Router, Request, Response, and View.
Reusable code helps us avoid expending redundant coding effort. But, if you don’t know what path to travel when it comes to reusing implementation, you’ll benefit from this walk-through of the Inheritance/Composition/Delegation trio in an attempt to showcase, side by side, some of their most appealing virtues and clunky drawbacks.
Managing Class Dependencies: An Introduction to Dependency Injection, Service Locators, and Factories, Part 2
This is the second part of the two-part series discussing ways to manage your class dependencies. This time around the focus is on the Service Locator pattern and Dependency Injection Containers.