PHP Objects, Patterns, and Practice, Third Edition

Book description

This book takes you beyond the PHP basics to the enterprise development practices used by professional programmers. Updated for PHP 5.3 with new sections on closures, namespaces, and continuous integration, this edition will teach you about object features such as abstract classes, reflection, interfaces, and error handling. You'll also discover object tools to help you learn more about your classes, objects, and methods.

Then you'll move into design patterns and the principles that make patterns powerful. You'll learn both classic design patterns and enterprise and database patterns with easy-to-follow examples.

Finally, you'll discover how to put it all into practice to help turn great code into successful projects. You'll learn how to manage multiple developers with Subversion, and how to build and install using Phing and PEAR. You'll also learn strategies for automated testing and building, including continuous integration.

Taken together, these three elements—object fundamentals, design principles, and best practices—will help you develop elegant and rock-solid systems.

Table of contents

  1. PHP Objects, Patterns, and Practice, Third Edition
    1. Copyright
    2. Contents at a Glance
    3. Contents (1/3)
    4. Contents (2/3)
    5. Contents (3/3)
    6. About the Author
    7. About the Technical Reviewer
    8. Acknowledgments
    9. Introduction to the Third Edition
    10. Part 1: Introduction
      1. Chapter 1: PHP: Design and Management (1/2)
      2. Chapter 1: PHP: Design and Management (2/2)
        1. The Problem
        2. PHP and Other Languages
        3. About This Book
        4. Summary
    11. Part 2: Objects
      1. Chapter 2: PHP and Objects
        1. The Accidental Success of PHP Objects
        2. Into the Future
        3. Advocacy and Agnosticism: The Object Debate
        4. Summary
      2. Chapter 3: Object Basics (1/6)
      3. Chapter 3: Object Basics (2/6)
      4. Chapter 3: Object Basics (3/6)
      5. Chapter 3: Object Basics (4/6)
      6. Chapter 3: Object Basics (5/6)
      7. Chapter 3: Object Basics (6/6)
        1. Classes and Objects
        2. Setting Properties in a Class
        3. Working with Methods
        4. Arguments and Types
        5. Inheritance
        6. Summary
      8. Chapter 4: Advanced Features (1/6)
      9. Chapter 4: Advanced Features (2/6)
      10. Chapter 4: Advanced Features (3/6)
      11. Chapter 4: Advanced Features (4/6)
      12. Chapter 4: Advanced Features (5/6)
      13. Chapter 4: Advanced Features (6/6)
        1. Static Methods and Properties
        2. Constant Properties
        3. Abstract Classes
        4. Interfaces
        5. Late Static Bindings: The static Keyword
        6. Handling Errors
        7. Final Classes and Methods
        8. Working with Interceptors
        9. Defining Destructor Methods
        10. Copying Objects with __clone()
        11. Defining String Values for Your Objects
        12. Callbacks, Anonymous Functions and Closures
        13. Summary
      14. Chapter 5: Object Tools (1/6)
      15. Chapter 5: Object Tools (2/6)
      16. Chapter 5: Object Tools (3/6)
      17. Chapter 5: Object Tools (4/6)
      18. Chapter 5: Object Tools (5/6)
      19. Chapter 5: Object Tools (6/6)
        1. PHP and Packages
        2. The Class and Object Functions
        3. The Reflection API
        4. Summary
      20. Chapter 6: Objects and Design (1/5)
      21. Chapter 6: Objects and Design (2/5)
      22. Chapter 6: Objects and Design (3/5)
      23. Chapter 6: Objects and Design (4/5)
      24. Chapter 6: Objects and Design (5/5)
        1. Defining Code Design
        2. Object-Oriented and Procedural Programming
        3. Choosing Your Classes
        4. Polymorphism
        5. Encapsulation
        6. Forget How to Do It
        7. Four Signposts
        8. The UML
        9. Summary
    12. Part 3: Patterns
      1. Chapter 7: What Are Design Patterns? Why Use Them? (1/2)
      2. Chapter 7: What Are Design Patterns? Why Use Them? (2/2)
        1. What Are Design Patterns?
        2. A Design Pattern Overview
        3. The Gang of Four Format
        4. Why Use Design Patterns?
        5. PHP and Design Patterns
        6. Summary
      3. Chapter 8: Some Pattern Principles (1/3)
      4. Chapter 8: Some Pattern Principles (2/3)
      5. Chapter 8: Some Pattern Principles (3/3)
        1. The Pattern Revelation
        2. Composition and Inheritance
        3. Decoupling
        4. Code to an Interface, Not to an Implementation
        5. The Concept That Varies
        6. Patternitis
        7. The Patterns
        8. Summary
      6. Chapter 9: Generating Objects (1/5)
      7. Chapter 9: Generating Objects (2/5)
      8. Chapter 9: Generating Objects (3/5)
      9. Chapter 9: Generating Objects (4/5)
      10. Chapter 9: Generating Objects (5/5)
        1. Problems and Solutions in Generating Objects
        2. The Singleton Pattern
        3. Factory Method Pattern
        4. Abstract Factory Pattern
        5. But That’s Cheating!
        6. Summary
      11. Chapter 10: Patterns for Flexible Object Programming (1/4)
      12. Chapter 10: Patterns for Flexible Object Programming (2/4)
      13. Chapter 10: Patterns for Flexible Object Programming (3/4)
      14. Chapter 10: Patterns for Flexible Object Programming (4/4)
        1. Structuring Classes to Allow Flexible Objects
        2. The Composite Pattern
        3. The Decorator Pattern
        4. The Facade Pattern
        5. Summary
      15. Chapter 11: Performing and Representing Tasks (1/7)
      16. Chapter 11: Performing and Representing Tasks (2/7)
      17. Chapter 11: Performing and Representing Tasks (3/7)
      18. Chapter 11: Performing and Representing Tasks (4/7)
      19. Chapter 11: Performing and Representing Tasks (5/7)
      20. Chapter 11: Performing and Representing Tasks (6/7)
      21. Chapter 11: Performing and Representing Tasks (7/7)
        1. The Interpreter Pattern
        2. The Strategy Pattern
        3. The Observer Pattern
        4. The Visitor Pattern
        5. The Command Pattern
        6. Summary
      22. Chapter 12: Enterprise Patterns (1/11)
      23. Chapter 12: Enterprise Patterns (2/11)
      24. Chapter 12: Enterprise Patterns (3/11)
      25. Chapter 12: Enterprise Patterns (4/11)
      26. Chapter 12: Enterprise Patterns (5/11)
      27. Chapter 12: Enterprise Patterns (6/11)
      28. Chapter 12: Enterprise Patterns (7/11)
      29. Chapter 12: Enterprise Patterns (8/11)
      30. Chapter 12: Enterprise Patterns (9/11)
      31. Chapter 12: Enterprise Patterns (10/11)
      32. Chapter 12: Enterprise Patterns (11/11)
        1. Architecture Overview
        2. Cheating Before We Start
        3. The Presentation Layer
        4. The Business Logic Layer
        5. Summary
      33. Chapter 13: Database Patterns (1/8)
      34. Chapter 13: Database Patterns (2/8)
      35. Chapter 13: Database Patterns (3/8)
      36. Chapter 13: Database Patterns (4/8)
      37. Chapter 13: Database Patterns (5/8)
      38. Chapter 13: Database Patterns (6/8)
      39. Chapter 13: Database Patterns (7/8)
      40. Chapter 13: Database Patterns (8/8)
        1. The Data Layer
        2. Data Mapper
        3. Identity Map
        4. Unit of Work
        5. Domain Object Factory
        6. The Identity Object
        7. The Selection Factory and Update Factory Patterns
        8. What’s Left of Data Mapper Now?
        9. Summary
    13. Part 4: Practice
      1. Chapter 14: Good (and Bad) Practice (1/2)
      2. Chapter 14: Good (and Bad) Practice (2/2)
        1. Beyond Code
        2. Borrowing a Wheel
        3. Playing Nice
        4. Giving Your Code Wings
        5. Documentation
        6. Testing
        7. Continuous Integration
        8. Summary
      3. Chapter 15: An Introduction to PEAR and Pyrus (1/5)
      4. Chapter 15: An Introduction to PEAR and Pyrus (2/5)
      5. Chapter 15: An Introduction to PEAR and Pyrus (3/5)
      6. Chapter 15: An Introduction to PEAR and Pyrus (4/5)
      7. Chapter 15: An Introduction to PEAR and Pyrus (5/5)
        1. What Is PEAR?
        2. Phar Out with Pyrus
        3. Installing a Package
        4. Using a PEAR Package
        5. Creating Your Own PEAR Package
        6. Summary
      8. Chapter 16: Generating Documentation with phpDocumentor (1/3)
      9. Chapter 16: Generating Documentation with phpDocumentor (2/3)
      10. Chapter 16: Generating Documentation with phpDocumentor (3/3)
        1. Why Document?
        2. Installation
        3. Generating Documentation
        4. DocBlock Comments
        5. Documenting Classes
        6. File-Level Documentation
        7. Documenting Properties
        8. Documenting Methods
        9. Creating Links in Documentation
        10. Summary
      11. Chapter 17: Version Control with Subversion (1/4)
      12. Chapter 17: Version Control with Subversion (2/4)
      13. Chapter 17: Version Control with Subversion (3/4)
      14. Chapter 17: Version Control with Subversion (4/4)
        1. Why Use Version Control?
        2. Getting Subversion
        3. Configuring a Subversion Repository
        4. Beginning a Project
        5. Updating and Committing
        6. Adding and Removing Files and Directories
        7. Tagging and Exporting a Release
        8. Branching a Project
        9. Summary
      15. Chapter 18: Testing with PHPUnit (1/6)
      16. Chapter 18: Testing with PHPUnit (2/6)
      17. Chapter 18: Testing with PHPUnit (3/6)
      18. Chapter 18: Testing with PHPUnit (4/6)
      19. Chapter 18: Testing with PHPUnit (5/6)
      20. Chapter 18: Testing with PHPUnit (6/6)
        1. Functional Tests and Unit Tests
        2. Testing by Hand
        3. Introducing PHPUnit
        4. Writing Web Tests
        5. A Note of Caution
        6. Summary
      21. Chapter 19: Automated Build with Phing (1/4)
      22. Chapter 19: Automated Build with Phing (2/4)
      23. Chapter 19: Automated Build with Phing (3/4)
      24. Chapter 19: Automated Build with Phing (4/4)
        1. What Is Phing?
        2. Getting and Installing Phing
        3. Composing the Build Document
        4. Summary
      25. Chapter 20: Continuous Integration (1/5)
      26. Chapter 20: Continuous Integration (2/5)
      27. Chapter 20: Continuous Integration (3/5)
      28. Chapter 20: Continuous Integration (4/5)
      29. Chapter 20: Continuous Integration (5/5)
        1. What Is Continuous Integration?
        2. CruiseControl and phpUnderControl
        3. Summary
    14. Part 5: Conclusion
      1. Chapter 21: Objects, Patterns, Practice (1/2)
      2. Chapter 21: Objects, Patterns, Practice (2/2)
        1. Objects
        2. Patterns
        3. Practice
        4. Summary
      3. Appendix A: Bibliography
        1. Books
        2. Articles
        3. Sites
      4. Appendix B: A Simple Parser (1/4)
      5. Appendix B: A Simple Parser (2/4)
      6. Appendix B: A Simple Parser (3/4)
      7. Appendix B: A Simple Parser (4/4)
        1. The Scanner
        2. The Parser
    15. Index (1/6)
    16. Index (2/6)
    17. Index (3/6)
    18. Index (4/6)
    19. Index (5/6)
    20. Index (6/6)

Product information

  • Title: PHP Objects, Patterns, and Practice, Third Edition
  • Author(s): Matt Zandstra
  • Release date: June 2010
  • Publisher(s): Apress
  • ISBN: 9781430229254