Top 10 Books For PHP Developers
These books will help you learn more about PHP in detail and make you a better software engineer overall.
When I started my career in the web development world, I was mostly learning from video courses because that was my preferred way of learning as self-taught developer (even though I finished college back in 2012).
I was never really a book reader until later in my career, even though I spent a few years on the Laracasts forums helping people and learning from discussions.
These days, I learn from different learning resources but if I were to start learning modern PHP today, I would definitely start reading more books, because they do have a lot more detailed content and theory rather than the video courses.
Video courses are amazing for learning the tools and the language in general, by building projects, getting the hang of things, but books that really changed my way I think about building products these days.
It doesn't matter if you use Laravel, Symfony, Laminas, Spiral, (Open) Swoole, Hyperf, X or any other PHP framework.
If were to start from scratch today, I would read these books in this order and experiment on my own projects to get a better understanding of the concepts explained in them.
1. Learn PHP For the Web by Matthias Noback
This book will get you up to speed with the basics of PHP and give you a few small projects to build in your learning journey.
2. Front Line PHP by Spatie
This book will get you up to speed with the latest additions to PHP up to (the upcoming release of) 8.2 so that you can familiarize yourself what's possible to do with the modern PHP features that has been added in the most recent years.
3. Object Design Style Guide by Matthias Noback
This book will teach you everything about object oriented programming and the different types of objects in PHP.
4. Principles of Package Design by Matthias Noback
This book will teach you about applying the SOLID principles in PHP among other things.
5. Advanced Web Application Architecture by Matthias Noback
This book will teach you about some of the tactical patterns of Domain Driven Design and Hexagonal Architecture, which also has a full application built in PHP for you to check out.
I finished reading this book and I must say that it’s a great book with a lot of interesting ideas on how to manage your code for long-term projects by decoupling from the framework.
Highly recommended for people battling bugs.
When you read all of the content, you might think it’s an overkill, but you don’t really have a choice because as the project grows, you don’t want to lose morale and momentum, lose the bugs battle and slow down the implementation of new features.
I’ve said previously that working on big distributed systems is a completely different world, once you implement a feature, it gets harder to change later on due to the effort and time it requires for it to get implemented and tested.
I loved the examples in the book, all of it made sense, there’s even a whole application on GitHub to get the whole picture. The testing chapter gave me a different view and understanding about testing compared to what I’ve known and done so far in my client projects.
The ideas in the book are not exactly for people who are working alone on their own projects because they won’t see the benefits right away compared to a project that is being built faster in a team of multiple people but they are worth checking out just in case they need them.
If you try to apply all of these ideas at once with all of the rules and tools mentioned, you would most likely give up and probably want to go to live on a farm somewhere and I’ve thought of doing that sometimes, because the more I learn, the less I know and it scares me.
I still don’t think that people want to write code like this just for the sake of it but the main goal is to have a better chance of fighting against bugs and business requirements in the long term, along with saving a ton of money for the business.
6. Domain Driven Design in PHP by Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary
This book will teach you about some of the tactical patterns of Domain Driven Design and Hexagonal Architecture, from a different point of view compared to the previous book. This book also has a full PHP app example.
I highly recommend the DDD in PHP book first because it has some great ideas and examples about how to think, code and design complex long term apps.
DDD might be overkill for the apps that are not as complex or when you are working alone on a CRUD based app trying to implement everything quickly just so that you are done as soon as possible but they are just ideas which can help you in some cases if you ever get there.
The good thing about the book is that it provides the pros and cons of each architecture and approach.
7. CQRS By Example by Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary
This book will teach you about Command-Query Responsibility Segregation and how to think about it and use it in PHP. This book also has a full app example for reference.
I highly recommend it, especially if you want to or work on a distributed system. I loved it because of how detailed the examples are and how they think in terms of designing the code first.
It also has some ideas about how to think and approach the design of the features.
8. Recipes For Decoupling by Matthias Noback
This book will teach you about decoupling your business logic / domain code from the framework of choice, and how to create PHPStan rules to stop others from misusing the rules of writing code.
9. Rector - The Power of Automated Refactoring by Matthias Noback and Tomas Votruba
This book will teach you everything you need to know about how to automatically refactor and upgrade your PHP code with Rector.
10. Microservices For Everyone by Matthias Noback
This book will teach you about Microservices, pros and cons of using them and how to implement them in PHP. This book has a great Microservices example for reference.
Bonus 1: Thinking Functionally in PHP by Larry Garfield
This book will teach you about the functional programming concepts and how you can apply them while working with PHP.
Bonus 2: The Art of PostgreSQL by Dimitri Fontaine
This book will teach you everything you need to know about using PostgreSQL
Bonus 3: Mastering Swoole by Bruce Dou
This book will teach you about (Open) Swoole, as well as some of the async programming concepts and how you can apply them when working with PHP.
Bonus 4: MySQL Cookbook (4th Edition) by Sveta Smirnova and Alkin Tezuysal
This book contains a lot of examples that you can use to learn MySQL, from writing different types of queries to manage and administer the database.
Bonus 5: Efficient MySQL Performance by Daniel Nichter
Bonus 6: MySQL 8 Query Performance Tuning by Jesper Wisborg Krogh
Bonus 7: MySQL Concurrency by Jesper Wisborg Krogh
Bonus 8: High Performance MySQL by Silvia Botros, Jeremy Tinley
These 4 books will give you more details and ideas how to optimize the database and write performant queries in general.
Bonus 9: The Grumpy Programmer's Guide To Testing PHP Applications by Chris Hartjes
This will book will teach you everything you need to know about testing and how to write different types of tests.
Bonus 10: Build APIs You Won't Hate By Phil Strurgeon
This book will teach you about implementing REST APIs, HATEOS, caching, content negotiation, versioning, URI formatting, authentication and more.
Bonus 11: Minimum Viable SQL Patterns by Ergest Xheblati
This is a book about SQL Patterns. Patterns describe problems that occur over and over in our professional settings.
Bonus 12: The Database Cookbook For Developers by Tobias Petry
Tobias has been posting tips on Twitter for a year so he compiled all of his tips in this free ebook. It will help you and give you some additional ideas, tips and tricks about how to write specific queries for specific problems.
I read some of these and I do have some others that are ready to be read soon as well but the ones that I read already changed the mindset of how I approach and build apps. Some of these books may be a little bit advanced for you but they are worth reading if you ask me.
The PHP related books mostly contain native PHP code but some of them might use Laravel or Symfony as a framework in order to show the examples easily.
Don't worry about some of the code being outdated in some of the older books, the ideas are still relevant today.
These books also contain other book recommendations in them so you will have endless books to read after you are done with these. If you have any other books to recommend, feel free to mention them by replying to this tweet.
Matthias Noback created a list of books with 20% discount, so if the links in this blog post do not have a discount, use his links if you want to buy any of his books.