Expert

The Null Object Pattern – Polymorphism in Domain Models

The Null Object Pattern - Polymorphism in Domain Models

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.

Compile PHP on Windows

Compile PHP on Windows

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 Need for Speed: Profiling PHP with XHProf and XHGui

The Need for Speed: Profiling PHP with XHProf and XHGui

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.

Patterns for Flexible View Handling, Part 1 – Working with Composites

Flexible View Manipulation

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.

This entry is part of the series Flexible View Manipulation

An Introduction to the Front Controller Pattern, Part 2

An Introduction to the Front Controller 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.

This entry is part of the series An Introduction to the Front Controller Pattern

An Introduction to the Front Controller Pattern, Part 1

An Introduction to the Front Controller Pattern

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.

This entry is part of the series An Introduction to the Front Controller Pattern

Writing a RESTful Web Service with Slim

Write a RESTful Web Service with Slim

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.

Managing Class Dependencies: An Introduction to Dependency Injection, Service Locators, and Factories, Part 2

Managing Class Dependencies: An Introduction to Dependency Injection, Service Locators, and Factories

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.

© 1998-2012 SitePoint Pty. Ltd. All Rights Reserved