Search and Find
Service
Contents at a Glance
5
Contents
7
About the Author
17
About the Technical Reviewer
18
Acknowledgments
19
Introduction to the First Edition
20
Introduction to the Second Edition
21
Introduction
22
PHP: Design and Management
23
The Problem
23
PHP and Other Languages
24
About This Book
26
Summary
28
Objects
29
PHP and Objects
30
The Accidental Success of PHP Objects
30
Into the Future: PHP 6
33
Advocacy and Agnosticism: The Object Debate
34
Summary
34
Object Basics
35
Classes and Objects
35
Setting Properties in a Class
37
Working with Methods
40
Arguments and Types
43
Inheritance
48
Summary
62
Advanced Features
63
Static Methods and Properties
63
Constant Properties
66
Abstract Classes
67
Interfaces
69
Handling Errors
71
Final Classes and Methods
77
Working with Interceptors
78
Defining Destructor Methods
82
Copying Objects with __ clone()
84
Defining String Values for Your Objects
86
Summary
87
Object Tools
88
PHP and Packages
88
The Class and Object Functions
95
The Reflection API
101
Summary
112
Objects and Design
113
Defining Code Design
113
Object- Oriented and Procedural Programming
114
Choosing Your Classes
119
Polymorphism
120
Encapsulation
122
Forget How to Do It
123
Four Signposts
124
The UML
125
Summary
134
Patterns
135
What Are Design Patterns? Why Use Them?
136
What Are Design Patterns?
136
A Design Pattern Overview
138
The Gang of Four Format
140
Why Use Design Patterns?
140
PHP and Design Patterns
142
Summary
143
Some Pattern Principles
144
The Pattern Revelation
144
Composition and Inheritance
145
Decoupling
150
Code to an Interface, Not to an Implementation
152
The Concept That Varies
153
Patternitis
154
The Patterns
154
Summary
155
Generating Objects
156
Problems and Solutions in Generating Objects
156
The Singleton Pattern
160
Factory Method Pattern
164
Abstract Factory Pattern
169
But That's Cheating!
179
Summary
180
Patterns for Flexible Object Programming
181
Structuring Classes to Allow Flexible Objects
181
The Composite Pattern
182
The Decorator Pattern
191
The Facade Pattern
197
Summary
200
Performing and Representing Tasks
201
The Interpreter Pattern
201
The Strategy Pattern
211
The Observer Pattern
216
The Visitor Pattern
223
The Command Pattern
230
Summary
235
Enterprise Patterns
236
Architecture Overview
236
Cheating Before We Start
240
The Presentation Layer
250
The Business Logic Layer
280
Summary
288
Database Patterns
289
The Data Layer
289
Data Mapper
290
Identity Map
303
Unit of Work
307
Domain Object Factory
314
The Identity Object
317
The Selection Factory and Update Factory Patterns
323
What's Left of Data Mapper Now?
327
Summary
330
Practice
331
Good (and Bad) Practice
332
Beyond Code
332
Borrowing a Wheel
333
Playing Nice
334
Giving Your Code Wings
335
Documentation
336
Testing
337
Summary
338
An Introduction to PEAR
339
What Is PEAR?
340
Installing a Package with PEAR
341
Using a PEAR Package
343
Creating Your Own PEAR Package
348
Summary
362
Generating Documentation with phpDocumentor
363
Why Document?
363
Installation
364
Generating Documentation
365
DocBlock Comments
367
Documenting Classes
368
File- Level Documentation
370
Documenting Properties
370
Documenting Methods
372
Creating Links in Documentation
374
Summary
377
Version Control with CVS
378
Why Use Version Control?
378
Getting CVS
379
Configuring a CVS Repository
380
Beginning a Project
383
Updating and Committing
385
Adding and Removing Files and Directories
389
Tagging and Exporting a Release
392
Branching a Project
394
Summary
398
Testing with PHPUnit
399
Functional Tests and Unit Tests
399
Testing by Hand
400
Introducing PHPUnit
402
A Note of Caution
417
Summary
419
Automated Build with Phing
420
What Is Phing?
420
Getting and Installing Phing
421
Composing the Build Document
422
Summary
439
Conclusion
440
Objects, Patterns, Practice
441
Objects
441
Patterns
444
Practice
446
Summary
449
Appendixes
450
Bibliography
451
Books
451
Articles
452
Sites
452
A Simple Parser
453
The Scanner
453
The Parser
461
Index
475
All prices incl. VAT