Object-oriented programming in PHP
This page serves as a complete guide to OOP in PHP. You'll learn all the basic and advanced programming methods, see dozens of examples, and write even better code and reusable applications.
Introduction
- The basic philosophy of object-oriented programming, thinking object-oriented
- Index and explanation of terms
- Motivation - why program object-oriented? What are the benefits?
- Why and how to use frameworks and libraries
Parts of the series
- OOP basics, class definition and instance creation
- Constructor, methods and passing input
- The principle of encapsulation
Upcoming articles
- Dedication and Visibility
- Comparisons vs. Identity
- Data validation, exceptions, and error catching
- Static vs. instance passing
- Service configuration and constants
- Object types: class, object, service, entity, value-object
- interface, use in inheritance and abstract class
- Special magic methods,
__toStringand magic in PHP - Advanced object handling, the
instanceofoperator - Namespaces and the principle of library development
- Fluent Interfaces, Nette Forms example
Design patterns and tricks in OOP
When programming in objects, there are many clever tips and recommendations that if you follow, will very effectively improve the readability, reusability and maintainability of the entire application. Think hard and plan for the future, because it will come sooner than you think. The articles describe the most common scenarios that I address with developers in my consultations.
- What are design patterns and what are they for?
- Autoloading classes by name from disk
- Dependency injection, introduction to the topic and getting instances
- The principle of single responsibility
- Factories, singleton and statics
- Encapsulating data in type entities (Doctrine)