■ CONTENTS
- Part 1: Introduction............................................................................................................................. ■Introduction to the Third Edition xx
- ■Chapter 1: PHP: Design and Management .......................................................................................
- Part 2: Objects ....................................................................................................................................
- ■Chapter 2: PHP and Objects ...........................................................................................................
- ■Chapter 3: Object Basics ...............................................................................................................
- ■Chapter 4: Advanced Features.......................................................................................................
- ■Chapter 5: Object Tools..................................................................................................................
- ■Chapter 6: Objects and Design ......................................................................................................
- Part 3: Patterns...............................................................................................................................
- ■Chapter 7: What Are Design Patterns? Why Use Them? ..............................................................
- ■Chapter 8: Some Pattern Principles ............................................................................................1
- ■Chapter 9: Generating Objects .....................................................................................................
- ■Chapter 10: Patterns for Flexible Object Programming...............................................................
- ■Chapter 11: Performing and Representing Tasks........................................................................
- ■Chapter 12: Enterprise Patterns ..................................................................................................
- ■Chapter 13: Database Patterns....................................................................................................
- Part 4: Practice ...............................................................................................................................
- ■Chapter 14: Good (and Bad) Practice ..........................................................................................31
- ■Chapter 15: An Introduction to PEAR and Pyrus..........................................................................
- ■Chapter 16: Generating Documentation with phpDocumentor ....................................................
- ■Chapter 17: Version Control with Subversion..............................................................................
- ■Chapter 18: Testing with PHPUnit................................................................................................
- ■Chapter 19: Automated Build with Phing ....................................................................................
- ■Chapter 20: Continuous Integration.............................................................................................
- Part 5: Conclusion...........................................................................................................................
- ■Chapter 21: Objects, Patterns, Practice ......................................................................................45
- ■Appendix A: Bibliography ............................................................................................................
- ■Appendix B: A Simple Parser.......................................................................................................
- ■Index............................................................................................................................................
- Change Embraced: PHP 5 .................................................................................................................... vi
- Into the Future
- Advocacy and Agnosticism: The Object Debate............................................................
- Summary.......................................................................................................................
- ■Chapter 3: Object Basics .....................................................................................
- Classes and Objects......................................................................................................
- A First Class .........................................................................................................................................
- A First Object (or Two) .........................................................................................................................
- Setting Properties in a Class........................................................................................
- Working with Methods
- Creating a Constructor Method ............................................................................................................
- Arguments and Types
- Primitive Types
- Taking the Hint: Object Types ..............................................................................................................
- Inheritance
- The Inheritance Problem ......................................................................................................................
- Working with Inheritance .....................................................................................................................
- Public, Private, and Protected: Managing Access to Your Classes ......................................................
- Summary.......................................................................................................................
- ■Chapter 4: Advanced Features ............................................................................
- Static Methods and Properties......................................................................................
- Constant Properties
- Abstract Classes
- Interfaces
- Late Static Bindings: The static Keyword..................................................................
- Handling Errors
- Exceptions............................................................................................................................................
- Final Classes and Methods
- Working with Interceptors
- Defining Destructor Methods
- Copying Objects with __clone() vii
- Defining String Values for Your Objects
- Callbacks, Anonymous Functions and Closures
- Summary.......................................................................................................................
- ■Chapter 5: Object Tools .......................................................................................
- PHP and Packages
- PHP Packages and Namespaces..........................................................................................................
- Autoload ...............................................................................................................................................
- The Class and Object Functions....................................................................................
- Looking for Classes..............................................................................................................................
- Learning About an Object or Class
- Learning About Methods ......................................................................................................................
- Learning About Properties ...................................................................................................................
- Learning About Inheritance ..................................................................................................................
- Method Invocation................................................................................................................................
- The Reflection API
- Getting Started
- Time to Roll Up Your Sleeves ...............................................................................................................
- Examining a Class ..............................................................................................................................
- Examining Methods..............................................................................................................................
- Examining Method Arguments .............................................................................................................
- Using the Reflection API.......................................................................................................................
- Summary.......................................................................................................................
- ■Chapter 6: Objects and Design ............................................................................
- Defining Code Design....................................................................................................
- Object-Oriented and Procedural Programming...........................................................
- Responsibility.....................................................................................................................................
- Cohesion ............................................................................................................................................
- Coupling .............................................................................................................................................
- Orthogonality......................................................................................................................................
- Choosing Your Classes................................................................................................
- Polymorphism viii
- Encapsulation
- Forget How to Do It
- Four Signposts
- Code Duplication ................................................................................................................................
- The Class Who Knew Too Much .........................................................................................................
- The Jack of All Trades........................................................................................................................
- Conditional Statements ......................................................................................................................
- The UML
- Class Diagrams
- Sequence Diagrams ...........................................................................................................................
- Summary.....................................................................................................................
- Part 3: Patterns ....................................................................................................
- ■Chapter 7: What Are Design Patterns? Why Use Them?....................................
- What Are Design Patterns?
- A Design Pattern Overview
- Name..................................................................................................................................................
- The Problem .......................................................................................................................................
- The Solution .......................................................................................................................................
- Consequences....................................................................................................................................
- The Gang of Four Format
- Why Use Design Patterns?
- A Design Pattern Defines a Problem
- A Design Pattern Defines a Solution
- Design Patterns Are Language Independent......................................................................................1
- Patterns Define a Vocabulary.............................................................................................................
- Patterns Are Tried and Tested ...........................................................................................................
- Patterns Are Designed for Collaboration ............................................................................................
- Design Patterns Promote Good Design ..............................................................................................
- PHP and Design Patterns
- Summary.....................................................................................................................
- ■Chapter 8: Some Pattern Principles .................................................................. ix
- The Pattern Revelation................................................................................................
- Composition and Inheritance
- The Problem .......................................................................................................................................
- Using Composition .............................................................................................................................
- Decoupling
- The Problem .......................................................................................................................................
- Loosening Your Coupling ...................................................................................................................
- Code to an Interface, Not to an Implementation
- The Concept That Varies
- Patternitis....................................................................................................................
- The Patterns................................................................................................................
- Patterns for Generating Objects .........................................................................................................
- Patterns for Organizing Objects and Classes .....................................................................................
- Task-Oriented Patterns ......................................................................................................................
- Enterprise Patterns ............................................................................................................................
- Database Patterns..............................................................................................................................
- Summary.....................................................................................................................
- ■Chapter 9: Generating Objects ..........................................................................
- Problems and Solutions in Generating Objects...........................................................
- The Singleton Pattern
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Factory Method Pattern
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Abstract Factory Pattern
- The Problem .......................................................................................................................................
- Implementation
- Consequences.................................................................................................................................... x
- Prototype............................................................................................................................................
- The Problem .......................................................................................................................................
- Implementation
- But That’s Cheating!
- Summary.....................................................................................................................
- ■Chapter 10: Patterns for Flexible Object Programming ....................................
- Structuring Classes to Allow Flexible Objects.............................................................
- The Composite Pattern................................................................................................
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Composite in Summary ......................................................................................................................
- The Decorator Pattern
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- The Facade Pattern
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Summary.....................................................................................................................
- ■Chapter 11: Performing and Representing Tasks .............................................
- The Interpreter Pattern................................................................................................
- The Problem .......................................................................................................................................
- Implementation
- Interpreter Issues ...............................................................................................................................
- The Strategy Pattern
- The Problem .......................................................................................................................................
- Implementation
- The Observer Pattern
- Implementation xi
- The Visitor Pattern
- The Problem .......................................................................................................................................
- Implementation
- Visitor Issues......................................................................................................................................
- The Command Pattern
- The Problem .......................................................................................................................................
- Implementation
- Summary.....................................................................................................................
- ■Chapter 12: Enterprise Patterns........................................................................
- Architecture Overview.................................................................................................
- The Patterns.......................................................................................................................................
- Applications and Layers .....................................................................................................................
- Cheating Before We Start............................................................................................
- Registry ..............................................................................................................................................
- Implementation
- The Presentation Layer
- Front Controller
- Application Controller.........................................................................................................................
- Page Controller
- Template View and View Helper ........................................................................................................
- The Business Logic Layer
- Transaction Script ..............................................................................................................................
- Domain Model
- Summary.....................................................................................................................
- ■Chapter 13: Database Patterns .........................................................................
- The Data Layer
- Data Mapper
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Identity Map xii
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Unit of Work
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Lazy Load ...........................................................................................................................................
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- Domain Object Factory................................................................................................
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- The Identity Object
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- The Selection Factory and Update Factory Patterns
- The Problem .......................................................................................................................................
- Implementation
- Consequences....................................................................................................................................
- What’s Left of Data Mapper Now?
- Summary.....................................................................................................................
- Part 4: Practice ....................................................................................................
- ■Chapter 14: Good (and Bad) Practice ................................................................
- Beyond Code
- Borrowing a Wheel
- Playing Nice
- Giving Your Code Wings xiii
- Documentation............................................................................................................
- Testing
- Continuous Integration................................................................................................
- Summary.....................................................................................................................
- ■Chapter 15: An Introduction to PEAR and Pyrus ...............................................
- What Is PEAR?.............................................................................................................
- Phar Out with Pyrus
- Installing a Package
- PEAR Channels...................................................................................................................................
- Using a PEAR Package................................................................................................
- Handling PEAR Errors.........................................................................................................................
- Creating Your Own PEAR Package
- package.xml.......................................................................................................................................
- Package Elements..............................................................................................................................
- The contents Element .....................................................................................................................33
- Dependencies
- Tweaking Installation with phprelease...........................................................................................
- Preparing a Package for Shipment ....................................................................................................
- Setting Up Your Own Channel ............................................................................................................
- Summary.....................................................................................................................
- ■Chapter 16: Generating Documentation with phpDocumentor..........................
- Why Document?
- Installation
- Generating Documentation
- DocBlock Comments
- Documenting Classes
- File-Level Documentation
- Documenting Properties
- Documenting Methods
- Creating Links in Documentation xiv
- Summary.....................................................................................................................
- ■Chapter 17: Version Control with Subversion ...................................................
- Why Use Version Control?
- Getting Subversion......................................................................................................
- Configuring a Subversion Repository..........................................................................
- Creating a Repository.........................................................................................................................
- Beginning a Project.....................................................................................................
- Updating and Committing
- Adding and Removing Files and Directories
- Adding a File ......................................................................................................................................
- Removing a File
- Adding a Directory .............................................................................................................................
- Removing Directories.........................................................................................................................
- Tagging and Exporting a Release
- Tagging a Project ...............................................................................................................................
- Exporting a Project.............................................................................................................................
- Branching a Project.....................................................................................................
- Summary.....................................................................................................................
- ■Chapter 18: Testing with PHPUnit .....................................................................
- Functional Tests and Unit Tests
- Testing by Hand
- Introducing PHPUnit
- Creating a Test Case ..........................................................................................................................
- Assertion Methods .............................................................................................................................
- Testing Exceptions .............................................................................................................................
- Running Test Suites ...........................................................................................................................
- Constraints .........................................................................................................................................
- Mocks and Stubs ...............................................................................................................................
- Tests Succeed When They Fail ..........................................................................................................
- Writing Web Tests xv
- Refactoring a Web Application for Testing.........................................................................................
- Simple Web Testing ...........................................................................................................................
- Introducing Selenium .........................................................................................................................
- A Note of Caution
- Summary.....................................................................................................................
- ■Chapter 19: Automated Build with Phing ..........................................................
- What Is Phing?
- Getting and Installing Phing
- Composing the Build Document..................................................................................
- Targets ...............................................................................................................................................
- Properties...........................................................................................................................................
- Types..................................................................................................................................................
- Tasks..................................................................................................................................................
- Summary.....................................................................................................................
- ■Chapter 20: Continuous Integration ..................................................................
- What Is Continuous Integration?
- Preparing a Project for CI ...................................................................................................................
- CruiseControl and phpUnderControl............................................................................
- Installing CruiseControl ......................................................................................................................
- Installing phpUnderControl.................................................................................................................
- Installing Your Project ........................................................................................................................
- Summary.....................................................................................................................
- Part 5: Conclusion ................................................................................................
- ■Chapter 21: Objects, Patterns, Practice ............................................................
- Objects
- Choice ................................................................................................................................................
- Encapsulation and Delegation............................................................................................................
- Decoupling .........................................................................................................................................
- Reusability .........................................................................................................................................
- Aesthetics ..........................................................................................................................................
- Patterns....................................................................................................................... xvi
- What Patterns Buy Us ........................................................................................................................
- Patterns and Principles of Design ......................................................................................................
- Practice
- Testing ...............................................................................................................................................
- Documentation...................................................................................................................................
- Version Control...................................................................................................................................
- Automated Build.................................................................................................................................
- Continuous Integration .......................................................................................................................
- What I Missed
- Summary.....................................................................................................................
- ■Appendix A: Bibliography..................................................................................
- Books
- Articles
- Sites
- ■Appendix B: A Simple Parser ............................................................................
- The Scanner
- The Parser...................................................................................................................
- ■Index .................................................................................................................