Email the Author
You can use this page to email Joseph Benharosh about The essentials of Object Oriented PHP.
About the Book
Why learn object-oriented PHP?
Over 80% of websites are now written in PHP, making it more important than ever for web developers to master this programming skill. Although the basics of PHP are easy to learn, it is the knowledge of object-oriented PHP that separates the professionals from the hobbyists.
When using object-oriented programming, we organize the code in an efficient way, so it is easier to work with, develop and upgrade. Due to its many benefits, developers who master the craft of object-oriented PHP are a hot commodity in the job market among companies and enterprises that have a need for advanced online applications.
But this does not tell the full story. Consider the following facts :
- Procedural programming is inefficient
- PHP libraries are written in object-oriented PHP
- PHP frameworks, like Laravel, Symfony, CodeIgniter and Yii rely on object-oriented code
- 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 the 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. It is also easier to add, replace or remove parts of code as it only has to be done once.
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. In fact, the knowledge of object-oriented PHP is a prerequisite for getting a job in the PHP world
- The code they write is better as it is less messy and doesn't repeat it self
- The code can be easily expanded with modern libraries that come from the thriving PHP community
With all of its benefits, programming in object-oriented PHP requires a different way of thinking. For this reason 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. It 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.
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 the essential skills for learning object-oriented programming. 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
- Constructing applications using interfaces and polymorphism
- The intimidating concept of dependency injection in a practical and easy-to-understand way
The book also covers the most valuable skill of integrating code and code libraries from other sources with the help of namespaces and Composer. Once you finish learning this skill, programming in PHP becomes much faster.
Who is this book for?
Obviously, this book is for procedural PHP developers who want to improve their skills and take their development skills 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 object-oriented languages like C++ and Java.
So, in summary, the book is for existing developers who want to learn object-oriented PHP.
Getting the most from this book
As already established, this book is designed for existing developers 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 the language is simple and the code examples are very basic. This simplicity is done on purpose so the learner can get a good grasp of the essentials of the language without being confused with unnecessary complicted language and code. But don't let this simplicity fool you because it is meant to assimilate in you the essentials of object-oriented PHP, some of them sophisticated and advanced, in the easiest way possible.
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 reader is guided through the process of writing code examples that are based on what he has just learned. This practice is where proper understanding develops as the learner repeatedly gets a chance to actively assimilate 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
I'm a senior web developer, an instructor and, the founder of PHPenthusiast.com, a learner-centered online tutorials website that teaches Object Oriented PHP on which this eBook is based. You can find out more at PHPenthusiast.com.