PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

C H A P T E R 12


■ ■ ■


Enterprise Patterns


PHP is first and foremost a language designed for the Web. And since its support for objects was
significantly extended in PHP 5, you can now take advantage of patterns hatched in the context of other
object-oriented languages, particularly Java.
I develop a single example in this chapter, using it to illustrate the patterns I cover. Remember,
though, that by choosing to use one pattern, you are not committed to using all the patterns that work
well with it. Nor should you feel that the implementations presented here are the only way you might go
about deploying these patterns. Use the examples here to help you understand the thrust of the patterns
described, and feel free to extract what you need for your projects.
Because of the amount of material to cover, this is one this book’s longest and most involved
chapters, and it may be a challenge to traverse in one sitting. It is divided into an introduction and two
main parts. These dividing lines might make good break points.
I also describe the individual patterns in the “Architecture Overview” section. Although these are
interdependent to some extent, you should be able to jump straight to any particular pattern and work
through it independently, moving on to related patterns at your leisure.
This chapter will cover



  • Architecture overview: An introduction to the layers that typically comprise an
    enterprise application

  • Registry pattern: Managing application data

  • Presentation layer: Tools for managing and responding to requests and for
    presenting data to the user

  • Business logic layer: Getting to the real purpose of your system: addressing
    business problems


Architecture Overview


With a lot of ground to cover, let’s kick off with an overview of the patterns to come, followed by an
introduction to building layered, or tiered, applications.

Free download pdf