About the Author |
|
xxi | |
About the Tecnical Reviewer |
|
xxiii | |
Acknowledgments |
|
xxv | |
Introduction |
|
xxvii | |
|
|
1 | (154) |
|
Chapter 1 PHP: Design and Management |
|
|
3 | (6) |
|
|
3 | (1) |
|
|
4 | (2) |
|
|
6 | (2) |
|
|
6 | (1) |
|
|
6 | (1) |
|
|
6 | (1) |
|
What's New in the Fifth Edition |
|
|
7 | (1) |
|
|
8 | (1) |
|
Chapter 2 PHP and Objects |
|
|
9 | (6) |
|
The Accidental Success of PHP Objects |
|
|
9 | (3) |
|
|
9 | (1) |
|
|
9 | (1) |
|
PHP 4 and the Quiet Revolution |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
12 | (1) |
|
Advocacy and Agnosticism: The Object Debate |
|
|
12 | (1) |
|
|
13 | (2) |
|
|
15 | (32) |
|
|
15 | (2) |
|
|
15 | (1) |
|
|
16 | (1) |
|
Setting Properties in a Class |
|
|
17 | (2) |
|
|
19 | (3) |
|
Creating a Constructor Method |
|
|
21 | (1) |
|
|
22 | (8) |
|
|
22 | (4) |
|
Taking the Hint: Object Types |
|
|
26 | (4) |
|
|
30 | (16) |
|
|
30 | (5) |
|
|
35 | (6) |
|
Public, Private, and Protected: Managing Access to Your Classes |
|
|
41 | (5) |
|
|
46 | (1) |
|
Chapter 4 Advanced Features |
|
|
47 | (52) |
|
Static Methods and Properties |
|
|
47 | (4) |
|
|
51 | (1) |
|
|
51 | (2) |
|
|
53 | (2) |
|
|
55 | (10) |
|
A Problem for Traits to Solve |
|
|
56 | (1) |
|
Defining and Using a Trait |
|
|
57 | (1) |
|
Using More than One Trait |
|
|
58 | (1) |
|
Combining Traits and Interfaces |
|
|
58 | (1) |
|
Managing Method Name Conflicts with insteadof |
|
|
59 | (2) |
|
Aliasing overridden trait methods |
|
|
61 | (1) |
|
Using static methods in traits |
|
|
61 | (1) |
|
Accessing Host Class Properties |
|
|
62 | (1) |
|
Defining Abstract Methods in Traits |
|
|
63 | (1) |
|
Changing Access Rights to Trait Methods |
|
|
64 | (1) |
|
Late Static Bindings: The static Keyword |
|
|
65 | (3) |
|
|
68 | (9) |
|
|
70 | (7) |
|
Final Classes and Methods |
|
|
77 | (1) |
|
|
78 | (1) |
|
Working with Interceptors |
|
|
79 | (6) |
|
Defining Destructor Methods |
|
|
85 | (2) |
|
Copying Objects with-clone() |
|
|
87 | (3) |
|
Defining String Values for Your Objects |
|
|
90 | (1) |
|
Callbacks, Anonymous Functions, and Closures |
|
|
91 | (4) |
|
|
95 | (2) |
|
|
97 | (2) |
|
|
99 | (34) |
|
|
99 | (13) |
|
PHP Packages and Namespaces |
|
|
99 | (9) |
|
|
108 | (4) |
|
The Class and Object Functions |
|
|
112 | (7) |
|
|
113 | (1) |
|
Learning About an Object or Class |
|
|
113 | (2) |
|
Getting a Fully Qualified String Reference to a Class |
|
|
115 | (1) |
|
|
115 | (2) |
|
Learning About Properties |
|
|
117 | (1) |
|
Learning About Inheritance |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
119 | (12) |
|
|
120 | (1) |
|
Time to Roll up Your Sleeves |
|
|
120 | (2) |
|
|
122 | (2) |
|
|
124 | (2) |
|
Examining Method Arguments |
|
|
126 | (1) |
|
|
127 | (4) |
|
|
131 | (2) |
|
Chapter 6 Objects and Design |
|
|
133 | (22) |
|
|
133 | (1) |
|
Object-Oriented and Procedural Programming |
|
|
134 | (5) |
|
|
138 | (1) |
|
|
138 | (1) |
|
|
139 | (1) |
|
|
139 | (1) |
|
|
139 | (1) |
|
|
140 | (2) |
|
|
142 | (1) |
|
|
142 | (1) |
|
|
143 | (1) |
|
|
143 | (1) |
|
The Class Who Knew Too Much |
|
|
143 | (1) |
|
|
144 | (1) |
|
|
144 | (1) |
|
|
144 | (9) |
|
|
144 | (7) |
|
|
151 | (2) |
|
|
153 | (2) |
|
|
155 | (220) |
|
Chapter 7 What Are Design Patterns? Why Use Them? |
|
|
157 | (8) |
|
What Are Design Patterns? |
|
|
157 | (2) |
|
A Design Pattern Overview |
|
|
159 | (1) |
|
|
159 | (1) |
|
|
159 | (1) |
|
|
159 | (1) |
|
|
160 | (1) |
|
|
160 | (1) |
|
|
161 | (1) |
|
A Design Pattern Defines a Problem |
|
|
161 | (1) |
|
A Design Pattern Defines a Solution |
|
|
161 | (1) |
|
Design Patterns Are Language Independent |
|
|
161 | (1) |
|
Patterns Define a Vocabulary |
|
|
161 | (1) |
|
Patterns Are Tried and Tested |
|
|
162 | (1) |
|
Patterns Are Designed for Collaboration |
|
|
162 | (1) |
|
Design Patterns Promote Good Design |
|
|
162 | (1) |
|
Design Patterns are Used By Popular Frameworks |
|
|
162 | (1) |
|
|
162 | (1) |
|
|
163 | (2) |
|
Chapter 8 Some Pattern Principles |
|
|
165 | (14) |
|
|
165 | (1) |
|
Composition and Inheritance |
|
|
166 | (6) |
|
|
166 | (3) |
|
|
169 | (3) |
|
|
172 | (3) |
|
|
172 | (1) |
|
|
173 | (2) |
|
Code to an Interface, Not to an Implementation |
|
|
175 | (1) |
|
|
176 | (1) |
|
|
177 | (1) |
|
|
177 | (1) |
|
Patterns for Generating Objects |
|
|
177 | (1) |
|
Patterns for Organizing Objects and Classes |
|
|
177 | (1) |
|
|
177 | (1) |
|
|
178 | (1) |
|
|
178 | (1) |
|
|
178 | (1) |
|
Chapter 9 Generating Objects |
|
|
179 | (32) |
|
Problems and Solutions in Generating Objects |
|
|
179 | (5) |
|
|
184 | (3) |
|
|
184 | (1) |
|
|
185 | (2) |
|
|
187 | (1) |
|
|
187 | (6) |
|
|
188 | (3) |
|
|
191 | (2) |
|
|
193 | (1) |
|
|
193 | (6) |
|
|
194 | (1) |
|
|
195 | (2) |
|
|
197 | (2) |
|
|
199 | (4) |
|
|
199 | (1) |
|
|
200 | (3) |
|
Pushing to the Edge: Service Locator |
|
|
203 | (2) |
|
Splendid Isolation: Dependency Injection |
|
|
205 | (4) |
|
|
205 | (1) |
|
|
206 | (2) |
|
|
208 | (1) |
|
|
209 | (2) |
|
Chapter 10 Patterns for Flexible Object Programming |
|
|
211 | (24) |
|
Structuring Classes to Allow Flexible Objects |
|
|
211 | (1) |
|
|
211 | (11) |
|
|
212 | (2) |
|
|
214 | (4) |
|
|
218 | (4) |
|
|
222 | (1) |
|
|
222 | (7) |
|
|
222 | (3) |
|
|
225 | (4) |
|
|
229 | (1) |
|
|
229 | (4) |
|
|
230 | (1) |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (2) |
|
Chapter 11 Performing and Representing Tasks |
|
|
235 | (42) |
|
|
235 | (10) |
|
|
235 | (1) |
|
|
236 | (9) |
|
|
245 | (1) |
|
|
245 | (5) |
|
|
246 | (1) |
|
|
247 | (3) |
|
|
250 | (9) |
|
|
253 | (6) |
|
|
259 | (8) |
|
|
259 | (2) |
|
|
261 | (5) |
|
|
266 | (1) |
|
|
267 | (5) |
|
|
267 | (1) |
|
|
267 | (5) |
|
|
272 | (4) |
|
|
272 | (3) |
|
|
275 | (1) |
|
|
276 | (1) |
|
Chapter 12 Enterprise Patterns |
|
|
277 | (50) |
|
|
277 | (3) |
|
|
277 | (1) |
|
|
278 | (2) |
|
|
280 | (6) |
|
|
280 | (2) |
|
|
282 | (4) |
|
|
286 | (31) |
|
|
286 | (11) |
|
|
297 | (13) |
|
|
310 | (5) |
|
Template View and View Helper |
|
|
315 | (2) |
|
|
317 | (9) |
|
|
318 | (4) |
|
|
322 | (4) |
|
|
326 | (1) |
|
Chapter 13 Database Patterns |
|
|
327 | (48) |
|
|
327 | (1) |
|
|
327 | (16) |
|
|
328 | (1) |
|
|
328 | (14) |
|
|
342 | (1) |
|
|
343 | (4) |
|
|
343 | (1) |
|
|
344 | (3) |
|
|
347 | (1) |
|
|
347 | (8) |
|
|
348 | (1) |
|
|
348 | (4) |
|
|
352 | (1) |
|
|
352 | (1) |
|
|
352 | (1) |
|
|
353 | (2) |
|
|
355 | (1) |
|
|
355 | (4) |
|
|
355 | (1) |
|
|
356 | (1) |
|
|
357 | (2) |
|
|
359 | (6) |
|
|
359 | (1) |
|
|
359 | (6) |
|
|
365 | (1) |
|
The Selection Factory and Update Factory Patterns |
|
|
365 | (5) |
|
|
366 | (1) |
|
|
366 | (4) |
|
|
370 | (1) |
|
What's Left of Data Mapper Now? |
|
|
370 | (3) |
|
|
373 | (2) |
|
|
375 | (190) |
|
Chapter 14 Good (and Bad) Practice |
|
|
377 | (8) |
|
|
377 | (1) |
|
|
378 | (1) |
|
|
379 | (1) |
|
|
380 | (1) |
|
|
380 | (1) |
|
|
381 | (1) |
|
|
381 | (1) |
|
|
382 | (1) |
|
|
383 | (2) |
|
|
385 | (14) |
|
|
385 | (1) |
|
What Are PHP Standards Recommendations? |
|
|
386 | (1) |
|
|
386 | (1) |
|
|
387 | (1) |
|
|
387 | (8) |
|
PSR-1 Basic Coding Standard |
|
|
388 | (2) |
|
|
390 | (3) |
|
Checking and Fixing your Code |
|
|
393 | (2) |
|
|
395 | (3) |
|
The Rules that Matter to Us |
|
|
395 | (3) |
|
|
398 | (1) |
|
Chapter 16 PHP Using and Creating Components with Composer |
|
|
399 | (12) |
|
|
399 | (1) |
|
|
400 | (1) |
|
Installing a (Set of) Package(s) |
|
|
400 | (3) |
|
Installing a Package from the Command Line |
|
|
401 | (1) |
|
|
401 | (1) |
|
|
402 | (1) |
|
|
403 | (1) |
|
Creating Your Own Package |
|
|
404 | (2) |
|
Adding Package Information |
|
|
404 | (1) |
|
|
405 | (1) |
|
Distribution Through Packagist |
|
|
406 | (3) |
|
|
409 | (1) |
|
|
410 | (1) |
|
Chapter 17 Version Control with Git |
|
|
411 | (24) |
|
|
411 | (1) |
|
|
412 | (1) |
|
Using an Online Git Repository |
|
|
413 | (2) |
|
|
415 | (2) |
|
Creating the Remote Repository |
|
|
415 | (2) |
|
|
417 | (3) |
|
|
420 | (1) |
|
|
420 | (4) |
|
Adding and Removing Files and Directories |
|
|
424 | (2) |
|
|
424 | (1) |
|
|
424 | (1) |
|
|
425 | (1) |
|
|
425 | (1) |
|
|
426 | (1) |
|
|
427 | (6) |
|
|
433 | (2) |
|
Chapter 18 Testing with PHPUnit |
|
|
435 | (30) |
|
Functional Tests and Unit Tests |
|
|
435 | (1) |
|
|
436 | (2) |
|
|
438 | (14) |
|
|
439 | (2) |
|
|
441 | (1) |
|
|
442 | (1) |
|
|
443 | (1) |
|
|
444 | (2) |
|
|
446 | (3) |
|
Tests Succeed When They Fail |
|
|
449 | (3) |
|
|
452 | (11) |
|
Refactoring a Web Application for Testing |
|
|
452 | (2) |
|
|
454 | (2) |
|
|
456 | (7) |
|
|
463 | (1) |
|
|
464 | (1) |
|
Chapter 19 Automated Build with Phing |
|
|
465 | (22) |
|
|
465 | (1) |
|
Getting and Installing Phing |
|
|
466 | (1) |
|
Composing the Build Document |
|
|
466 | (19) |
|
|
468 | (2) |
|
|
470 | (7) |
|
|
477 | (5) |
|
|
482 | (3) |
|
|
485 | (2) |
|
|
487 | (10) |
|
|
487 | (1) |
|
|
488 | (2) |
|
Choosing and Installing a Vagrant Box |
|
|
488 | (2) |
|
Mounting Local Directories on the Vagrant Box |
|
|
490 | (1) |
|
|
491 | (4) |
|
Setting Up the Web Server |
|
|
492 | (1) |
|
|
493 | (1) |
|
|
494 | (1) |
|
|
495 | (1) |
|
|
496 | (1) |
|
Chapter 21 Continuous Integration |
|
|
497 | (28) |
|
What Is Continuous Integration? |
|
|
497 | (26) |
|
Preparing a Project for CI |
|
|
498 | (11) |
|
Installing Jenkins Plug-ins |
|
|
509 | (2) |
|
Setting up the Git Public Key |
|
|
511 | (1) |
|
|
511 | (5) |
|
|
516 | (1) |
|
|
517 | (3) |
|
|
520 | (3) |
|
|
523 | (2) |
|
Chapter 22 Objects, Patterns, Practice |
|
|
525 | (10) |
|
|
525 | (2) |
|
|
526 | (1) |
|
Encapsulation and Delegation |
|
|
526 | (1) |
|
|
526 | (1) |
|
|
527 | (1) |
|
|
527 | (1) |
|
|
527 | (3) |
|
|
528 | (1) |
|
Patterns and Principles of Design |
|
|
529 | (1) |
|
|
530 | (3) |
|
|
530 | (1) |
|
|
531 | (1) |
|
|
531 | (1) |
|
|
531 | (1) |
|
|
532 | (1) |
|
|
532 | (1) |
|
|
533 | (2) |
|
Chapter 23 Appendix A: Bibliography |
|
|
535 | (4) |
|
|
535 | (1) |
|
|
535 | (1) |
|
|
536 | (3) |
|
Chapter 24 Appendix B: A Simple Parser |
|
|
539 | (26) |
|
|
539 | (9) |
|
|
548 | (17) |
Index |
|
565 | |