Resources for digging deeper into object oriented PHP

alt lala

Being a developer can be really tough: you have to create and maintain (sometimes complex) structures and in the same time you have to stick to shorter deadlines.

Some developers think that the main aim of their job is to produce code which works. I'd say it's the easy part of our work: the other difficult part is to build applications you can scale easily without passing hours in refactoring.

Object oriented programming can help you to reach this goal.

What means object oriented programming ? Putting objects everywhere in your application is far from enough to have what I call a well coded object oriented application. An application you can maintain and scale easily. You need to learn how to use objects properly.

Years after years I collected many resources on the subject which can help you to master the object oriented programming concepts. I list in this article the most useful ones, at least in order to learn the basics or to grow your knowledge in this topic.

However you can read all of those resources without really know how to use those concepts in practice (and even without really understand them). You have only one solution in order to mastering object oriented concepts: practice, practice and practice.

Create an object oriented side project, play with your new knowledge in some quick experimentations. Being a good developer comes with experience and practice, not only in reading theoretical articles.

Another good way to understand object oriented paradigm is to install a PHP framework and look at its structure. I put links to the most famous PHP frameworks at the end of this article as well.

Must have

If I had to choose only two resources for learning object oriented PHP, I'd choose those:

1) PHP Object, pattern and practice

This book is nearly perfect for learning object oriented development in PHP. It is clear, easy to read and full of examples.

The first part is about the difference between procedural and object oriented development and the second about the most famous design pattern and why they are so useful in practical situations.

2) Sample code for several design patterns in PHP

This project gathers the most useful and known design patterns in PHP. Very useful for a quick look when you think you can use those structures for a project.
It includes examples, UML schemas and a quick description for each pattern.

Basics

If you don't know anything about object and your knowledge is limited to procedural PHP, those first articles will be useful for you.

Official documentation about objects and classes
Object oriented PHP for beginners
From Procedural to Object Oriented PHP

Advanced

If you know what is an instance, an object or a class but you don't know how to use them and why, you should read this section.

Following some articles from culttt.com I really like. It is easy to read, explained simply and clearly.

Magic methods
Abstract classes
Interfaces
Exceptions
Reflection class
Traits

Sitepoint is as well a great community with a huge amount of interesting article for PHP web developers.

Magic Methods and Predefined Constants
Namespaces
Type hinting
Battle of the Autoloaders: PSR-0 vs. PSR-4

Those articles from different websites are very good as well:

9 magic methods in PHP
When to use static methods Good and bad habits in OOP

Expert

If you know what are abstract classes, interface, magic methods, namespace but you don't really now how to organise all those tools and when you should use them, those articles will explain you the big axes for designing object oriented architectures.

A beginner guide to design patterns
The when and why for design pattern
Most used design patterns
Sample code for several design patterns in PHP
Good slides on SOLID principles and design patters

Following some articles on the OOP principles: how you should design your applications and what you shouldn't do.
Even if it's not always possible to follow exactly those principles, it is always good to be close to them.

Three very important principles in OOP
How to Write Code That Embraces Change

The SOLID principles
From STUPID to SOLID code
Don't be STUPID: GRASP SOLID!
Object-calisthenics applied to PHP

Finally an article very interesting about the possible alternative to the very well used MVC pattern:

Alternatives to MVC

Videos

There are a lot of videos about OOP on youtube. Those channels gather videos for beginner and more advanced developers.

The basics of OOP
OOP for beginner and advanced developers
Brandon Savage - Design Patterns Workshop
27 Design Patterns Tutorials

Most used framework

As I said it can be very valuable to understand how a modern framework is structured.

Here some example:

Laravel
Symfony 2
Code Igniter
Phalcon PHP

This is not the end...

This article is made to evolve in the next months with more useful resources. Since then don't hesitate to add your proper resources for learning or mastering OOP in the comment section!

And of course, don't forget to practice !