PHP Objects, Patterns and Practice, 4th Edition, Matt Zandstra.pdf

(8077 KB) Pobierz
1373384661.033.png 1373384661.038.png 1373384661.039.png 1373384661.040.png 1373384661.001.png 1373384661.002.png 1373384661.003.png 1373384661.004.png
 
 
 
 
 
 
1373384661.005.png 1373384661.006.png
 
 
 
 
 
 
 
 
1373384661.007.png 1373384661.008.png
 
1373384661.009.png
 
1373384661.010.png
 
1373384661.011.png 1373384661.012.png
 
1373384661.013.png 1373384661.014.png 1373384661.015.png 1373384661.016.png 1373384661.017.png
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
1373384661.018.png 1373384661.019.png 1373384661.020.png 1373384661.021.png 1373384661.022.png 1373384661.023.png 1373384661.024.png 1373384661.025.png 1373384661.026.png 1373384661.027.png 1373384661.028.png 1373384661.029.png 1373384661.030.png 1373384661.031.png 1373384661.032.png 1373384661.034.png
Contents at a Glance
About the Author �������������������������������������������������������������������������������������������������������������� xxi
About the Technical Reviewer ���������������������������������������������������������������������������������������� xxiii
Acknowledgments ����������������������������������������������������������������������������������������������������������� xxv
Introduction ������������������������������������������������������������������������������������������������������������������� xxvii
Chapter 1: PHP: Design and Management
������������������������������������������������������������������������ 1
Chapter 2: Objects
����������������������������������������������������������������������������������������������������������� �7
Chapter 3: Object Basics
����������������������������������������������������������������������������������������������� �� 11
Chapter 4: Advanced Features
��������������������������������������������������������������������������������������� 37
Chapter 5: Object Tools
�������������������������������������������������������������������������������������������������� �� 81
Chapter 6: Objects and Design
������������������������������������������������������������������������������������� 111
Chapter 7: What Are Design Patterns? Why Use Them?
���������������������������������������������� �� 131
Chapter 8: Some Pattern Principles
����������������������������������������������������������������������������� 139
Chapter 9: Generating Objects
������������������������������������������������������������������������������������� �� 153
Chapter 10: Patterns for Flexible Object Programming
������������������������������������������������ 175
Chapter 11: Performing and Representing Tasks
��������������������������������������������������������� 195
Chapter 12: Enterprise Patterns
����������������������������������������������������������������������������������� 227
Chapter 13: Database Patterns
������������������������������������������������������������������������������������� 277
Chapter 14: Good (and Bad) Practice
��������������������������������������������������������������������������� 321
Chapter 15: An Introduction to PEAR and Pyrus
����������������������������������������������������������� 327
Chapter 16: Generating Documentation with phpDocumentor
������������������������������������� 351
v
1373384661.035.png
Contents at a GlanCe
Chapter 17: Version Control with Git
��������������������������������������������������������������������������� �� 365
Chapter 18: Testing with PHPUnit
�������������������������������������������������������������������������������� �� 383
Chapter 19: Automated Build with Phing
��������������������������������������������������������������������� 409
Chapter 20: Continuous Integration
����������������������������������������������������������������������������� �� 431
Chapter 21: Objects, Patterns, Practice
������������������������������������������������������������������������ 457
Appendix A: Bibliography
��������������������������������������������������������������������������������������������� 465
Appendix B: A Simple Parser
��������������������������������������������������������������������������������������� �� 467
Index�������������������������������������������������������������������������������������������������������������������������������� 489
vi
1373384661.036.png
Introduction
When I irst conceived of this book, object-oriented design in PHP was an esoteric topic. he intervening years
have not only seen the inexorable rise of PHP as an object-oriented language, but also the march of the framework.
Frameworks are incredibly useful, of course. hey manage the guts and the glue of many (perhaps, these days, most)
Web applications. What’s more, they often exemplify precisely the principles of design that this book explores.
here is, though, a danger for developers here, as there is in all useful APIs. his is the fear that one might ind
oneself relegated to userland , forced to wait for remote gurus to ix bugs or add features at their whim. It’s a short
step from this standpoint to a kind of exile in which one is left regarding the innards of a framework as advanced
magic, and one’s own work as not much more than a minor adornment stuck up on top of a mighty unknowable
infrastructure.
Although I’m an inveterate reinventor of wheels, the thrust of my argument is not that we should all throw away
our frameworks and build MVC applications from scratch (at least not always). It is rather that, as developers, we
should understand the problems that frameworks solve, and the strategies they use to solve them. We should be able
to evaluate frameworks not only functionally but in terms of the design decisions their creators have made, and to
judge the quality of their implementations. And yes, when the conditions are right, we should go ahead and build our
own spare and focused applications, and, over time, compile our own libraries of reusable code.
I hope this book goes some way toward helping PHP developers maintain design-oriented insight into their
platforms and libraries, and provides some of the conceptual tools needed when it’s time to go it alone.
I recently took a year or so out to return to school. his is something I recommend for all sorts of reasons. One
beneit is the new perspective you gain afterwards when you revisit a once-familiar world. I came back to consulting
and found that most of my old clients and contacts had taken the plunge and migrated to Git (I follow suit in this
edition). And everyone, but everyone, was calling their development methodology agile. However, of my irst four new
clients, three asked me to help evaluate hastily-built and inlexible codebases. Each project required the retroitting
of unit tests, the creation of basic documentation, and the design of automated build mechanisms before refactoring
could safely commence. I found myself drawing heavily on the tools and practices I discuss in the last section of
this book. I very much hope you ind them as useful and powerful as I do, and they help you to create robust and
lexible systems.
xxvii
1373384661.037.png
Zgłoś jeśli naruszono regulamin