News Archive
PhpRiot Newsletter
Your Email Address:

More information

Implementing the Observer Pattern with SplObserver and SplSubject

Note: This article was originally published at Zend Developer Zone on 10 June 2010.
Zend Developer Zone
As PHP applications grow into complex object-oriented systems, developers look to create centralized components to execute repetitive tasks. These include logging, emailing, redirects, and more. The Observer pattern is a commonly used design pattern to hook such components into an application during runtime, thereby making them reusable. Since PHP 5.1, there are two interfaces built into the Standard PHP Library (SPL) that can be implemented to use the Observer pattern in your application. They are SplSubject, and SplObserver .