essentials of Object… by Joseph Benharosh [PDF/iPad/Kindle]
The essentials of Object Oriented PHP
The essentials of Object Oriented PHP
The essentials of Object Oriented PHP

This book is 100% complete

Completed on 2017-01-30

About the Book

Object oriented programming came late to PHP. It has been around in other languages like C++, Ruby, Python and JavaScript for much longer, but its demand in PHP is becoming stronger. With that demand for the programming style there is an increasing demand for developers who can program in object oriented PHP. And those programmers typically earn considerably more than their fellow web developers whose background is only limited to procedural PHP.

But this does not tell the full story. Consider the following facts :

  • Procedural programming is inefficient
  • PHP frameworks rely on object oriented PHP
  • Drupal and other CMS systems are now object oriented
  • There are more and more parts of WordPress becoming object oriented

Let's expand on the first fact as it is the most important one - everything else flows from it, i.e. object oriented programming is gaining popularity because it is more efficient. There are great applications written in the procedural style of PHP, but even the best end up in spaghetti code where functions and variables are mixed together. Add in HTML, CSS and JavaScript to this mix and the code becomes something that is, well, inefficient. Object oriented code is more organized. Distinct units are created for a single purpose. This means it is easier to find things in the code (ending those days of spending hours trawling through lines of spaghetti code to find a single element). It is also easier to add, replace or remove parts of code as it only has to be done once. With procedural programming, on the other hand, it is necessary to change every instance. Finally, object oriented programming gives the opportunity to developers to integrate code libraries from other resources. This is done without worrying about name collisions, even though some of the functions in the code might have the same name.

So, back to the original question, why bother learning object oriented PHP?

The answer is:

  • It is increasingly common
  • Developers with this skill earn more
  • The code they write is better

Programming in object oriented PHP requires a different way of thinking. That is why it is important to get an understanding of the fundamentals.

What does the book cover?

This book covers the fundamentals of programming in object oriented PHP. This starts with the basics of writing in an object oriented style. That style applies to everything including classes, objects, methods and properties. It also covers how code in a class can be approached from within the class and, crucially, from outside it.

For example:

  • Creating classes
  • Adding properties to a class
  • Creating objects from a class
  • Setting an object's properties
  • Adding methods to a class

The book also shows developers how to write streaming code that is easier to digest and understand because it more closely resembles human language. Plus the book covers a number of other skills, hints, tips and tricks to make object oriented programming more efficient. This includes:

  • Protecting code inside classes from the outside
  • Object inheritance and how it reduces repetition, therefore saving time
  • Abstracting classes and methods so that code is organized better
  • Other code organizing tips
  • Constructing applications using interfaces and polymorphism
  • Integrating code from other sources and libraries with the help of namespaces

The book also covers the intimidating concept of dependency injection in a practical and easy-to-understand way. Once finished with the dependency injection chapter, object oriented programming becomes even faster.

Who is this book for?

Obviously, this book is for procedural PHP developers who want to improve their skills and take their programming development to a new level. It is also for programmers who have a very basic understanding of object oriented PHP, but who want to learn it properly and get more practice.

Others who will benefit are those programmers who have a background in other objected oriented languages like C++ and Java.

So, in summary, the book is for existing programmers who want to learn object oriented PHP as a new skill.

Getting the most from this book

As already established, this book is designed for existing programmers who want to expand their skill set with object oriented PHP. As a result it is written in a learn-then-practice form.

Every principle, idea or process is described in a simple and concise way. It is easy to read as there is no superfluous text. The flow is also structured so that the reader develops hooks to hang additional knowledge on as their understanding grows and develops.

The material is accompanied by relevant and elucidating code examples for improved understanding.

Once the foundations are laid, the learner gets a plethora of opportunities to practice and bring the material to life. In the practice opportunities, the learner is guided through the process of writing code examples that are based on what he has just learned. This is where proper understanding develops as the learner repeatedly gets a chance to practice what he has just learned.

It is not a passive learning tool. This book is designed to give developers knowledge and skills in object oriented PHP quickly. That is achieved through active learning where programmers think for themselves while reading the explanations and examples and practicing the material.

So, to get the most from this book, approach it with an open mind and be ready to get involved. By doing this you will get a good understanding of object oriented PHP with sufficient knowledge and confidence to apply it practically in your work.

About the Author

Joseph Benharosh
Joseph Benharosh

I'm a senior web developer, an instructor and, the founder of, a learner-centered online tutorials website that teaches Object Oriented PHP on which this eBook is based. You can find out more at

The Leanpub Unconditional, No Risk, 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms

Write and Publish on Leanpub

Authors and publishers use Leanpub to publish amazing in-progress and completed ebooks, just like this one. You can use Leanpub to write, publish and sell your book as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub