PHP 8 Objects, Patterns, and Practice: Volume 1, Mastering OO Enhancements and Design Patterns, 7th Edition
معرفی کتاب «PHP 8 Objects, Patterns, and Practice: Volume 1, Mastering OO Enhancements and Design Patterns, 7th Edition» نوشتهٔ Matt Zandstra، منتشرشده توسط نشر Apress L. P. در سال 2024. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «PHP 8 Objects, Patterns, and Practice: Volume 1, Mastering OO Enhancements and Design Patterns, 7th Edition» در دستهٔ برنامهنویسی قرار دارد.
Develop elegant and rock-solid systems using PHP, aided by three key elements: object fundamentals, design principles, and best practices. Now in its seventh 7th edition, this book has been fully updated for PHP 8.3 and split into two volumes to better accommodate its wealth of new content. Volume 1 covers objects and patterns, while Volume 2 focuses on tools and best practices. You’ll begin this volume by reviewing PHP's object-oriented features and other key topics such as class declarations, inheritance, and reflection. The second part of the book is devoted to design patterns. It explains the principles that make patterns powerful and covers many of the classic design patterns, including enterprise and database patterns. This volume provides a solid grounding in PHP's support for objects and builds on this foundation to apply the core principles of software design. This includes read only classes, enumerations, typed class constants, as well as various additions to argument and return types. The knowledge gained from this book will help you master the object-oriented enhancements and the design patterns available for PHP 8, paving the way for developing best practices in Volume 2. What You Will Learn Work with object fundamentals. Write classes and methods, instantiate objects, and create powerful class hierarchies using inheritance. Master advanced object-oriented features, including static methods and properties. Manage error conditions with exceptions and create abstract classes and interfaces. Use design principles to deploy objects and classes effectively in your projects. Discover a set of powerful patterns that you can implement in your own projects. Who This Book Is For Anyone with at least a basic knowledge of PHP who wants to use its object-oriented features in their projects. Table of Contents About the Author About the Technical Reviewer Acknowledgments Introduction Chapter 1: PHP: Design and Management The Problem PHP and Other Languages About These Books What’s New in the Seventh Edition Volume 1 Part 1: Objects Part 2: Patterns Summary Chapter 2: PHP and Objects The Accidental Success of PHP Objects In the Beginning: PHP/FI Syntactic Sugar: PHP 3 PHP 4 and the Quiet Revolution Change Embraced: PHP 5 PHP 7: Closing the Gap PHP 8: The Consolidation Continues 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 Constructor Property Promotion Default Arguments and Named Arguments Arguments and Types Base Types Base Types: An Example Some Other Type-Checking Functions Type Declarations: Class Types Type Declarations: Scalar Types mixed Types Union Types Intersection Types DNF Types: Combining Union and Intersection Type Declarations Nullable Types Return Type Declarations Inheritance The Inheritance Problem Working with Inheritance Constructors and Inheritance Invoking an Overridden Method Public, Private, and Protected: Managing Access to Your Classes Accessor Methods Typed Properties readonly Properties readonly Classes The ShopProduct Classes Summary Chapter 4: Advanced Features Static Methods and Properties Constant Properties Enumerations Backed Enumerations Enumerations with Methods Abstract Classes Interfaces Traits A Problem for Traits to Solve Defining and Using a Trait Using More Than One Trait Combining Traits and Interfaces Managing Method Name Conflicts with insteadof Aliasing Overridden Trait Methods Using Static Methods in Traits Accessing Host Class Properties Defining Abstract Methods in Traits Changing Access Rights to Trait Methods Late Static Bindings: The static Keyword Handling Errors Exceptions Throwing an Exception Subclassing Exception Cleaning Up After try/catch Blocks with finally Final Classes and Methods The Internal Error Class Working with Interceptors Defining Destructor Methods Copying Objects with __clone() Defining String Values for Your Objects Callbacks, Anonymous Functions, and Closures Anonymous Classes Summary Chapter 5: Object Tools PHP and Packages PHP Packages and Namespaces Namespaces to the Rescue Using the File System to Simulate Packages Emulating Namespaces with Underscores Include Paths Autoload The Class and Object Functions Looking for Classes Learning About an Object or Class Getting a Fully Qualified String Reference to a 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 Attributes Summary Chapter 6: Objects and Design Defining Code Design Object-Oriented and Procedural Programming Responsibility Cohesion Coupling Orthogonality Choosing Your Classes Polymorphism 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 Representing Classes Attributes Operations Describing Inheritance and Implementation Associations Aggregation and Composition Describing Use Using Notes Sequence Diagrams Summary 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 Patterns Define a Vocabulary Patterns Are Tried and Tested Patterns Are Designed for Collaboration Design Patterns Promote Good Design Design Patterns Are Used by Popular Frameworks PHP and Design Patterns Summary Chapter 8: Some Pattern Principles 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 Prototype The Problem Implementation Pushing to the Edge: Service Locator Splendid Isolation: Dependency Injection The Problem Implementation Dependency Injection from a Configuration File Dependency Injection with Attributes Dependency Injection with Autowire Support Dependency Injection with Programmatic Configuration Adding an Object to a Container The Entire Container Class Consequences 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 The Visitor Pattern The Problem Implementation Visitor Issues The Command Pattern The Problem Implementation The Null Object Pattern The Problem Implementation Summary Chapter 12: Enterprise Patterns Architecture Overview The Patterns Applications and Layers Creating and Discovering Object Instances Registry The Problem Implementation Consequences Inversion of Control The Presentation Layer Front Controller The Problem Implementation ApplicationHelper CommandResolver Request Response ViewManager A Command Overview Consequences More Flexible Routing Routing Implementation Application Controller The Problem Implementation The Front Controller Implementation Overview The Configuration File Compiling the Configuration File The AppController Class An Action Class Consequences Page Controller The Problem Implementation Consequences Template View and View Helper The Problem Implementation Consequences The Business Logic Layer Transaction Script The Problem Implementation Consequences Domain Model The Problem Implementation Consequences Summary Chapter 13: Database Patterns The Data Layer Data Mapper The Problem Implementation Handling Multiple Rows Collections and Domain Objects Consequences Lazy Load The Problem Implementation Consequences Identity Map The Problem Implementation Consequences Unit of Work The Problem Implementation Consequences Refactoring Tight Coupling 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 Chapter 14: Objects and Patterns Objects Choice Encapsulation and Delegation Decoupling Reusability Aesthetics Patterns What Patterns Buy Us Tried and Tested Patterns Suggest Other Patterns A Common Vocabulary Patterns Promote Design Patterns and Principles of Design Favor Composition over Inheritance Avoid Tight Coupling Code to an Interface, Not an Implementation Encapsulate the Concept That Varies Summary
دانلود کتاب PHP 8 Objects, Patterns, and Practice: Volume 1, Mastering OO Enhancements and Design Patterns, 7th Edition