Using dependency injection in PHP.
The WordPress open-source project is now 20 years old. In that time, PHP and JavaScript have changed a lot. There is still some old code from back then running and it works. That’s great, but if you’re writing PHP and JavaScript for WordPress now, we can do better.
In this 5 part ebook, I walk through different ways you can structure, refactor and test the PHP code you write for WordPress plugins using dependency injection.
This course is an eBook that will take about an hour to read. You can download the book in PDF and ePub format.
Less Foo, No Bar
I am not covering how to build a todo app as a WordPress plugin from scratch. This is about how to improve plugins that already exist.
This book is based on stuff I’m working on, all the code examples are copied from actual work I did. As much as possible, I linked to pull requests where you can see where I implemented these patterns.
Josh has taken a complex topic and broken it down in such an accessible way, that I doubt any developer of any level would get to the end of the book and not understand what’s going on. His use of real-world examples of code he’s written for production helps the reader follow the process: from quickly hacking together some code to solve a problem, to refactoring it for prime time.
What makes Josh’s writing stand out from most other technical books is his friendly style of writing, how effortlessly he makes complex topics easy to understand, and the little bits of humor and photography from his personal life sprinkled throughout the book.
❞
Jonathan Bossenger
WordPress Developer Educator at Automattic
Standard
$30
One copy of eBook
Site Membership
$120/year
eBook
Request code samples
Early Access

Josh is the author of about a bajillion WordPress development tutorials, two now three books about WordPress development, and is a contributor to WordPress core and many popular plugins.
What Is In The Book
- How to remove singletons
- Code examples based on plugins I’m working on now. Often with links to pull requests.
- How to write tests with phpunit for WordPress plugins
- How to make your plugin easier to extend by third-party developers
- Pictures of my dog, also flowers.
Also, it’s not very long.
By A Guy With ADD For Folks With A Lot Going On
Who has time for a 4-inch thick book or a 25-hour course? I don’t. Maybe beginners do, this isn’t an intro, it assumes you know object-oriented PHP. This should take an hour or two to read.