Stack OverflowWhat is the best PHP programming book?
[+162] [31] Halo
[2008-09-18 08:24:48]
[ php web-development books recommendation ]

I'm interested to find out what Stack Overflow believes the best PHP book is - both for those who are beginners to web programming as well as those who have previous programming experience (they don't have to be same book). "Best" includes being both reasonably up-to-date and encouraging best practices for secure, modern, PHP programming.

There seems to be a lot of books out there and unlike other languages there doesn't seem to be a single well-regarded book and it's hard to separate the wheat from the chaff, so I'm interested to see what the community believes is good - both for personal use and for future recommendation to others.

To clarify: I know of the PHP manual which is largely a reference, not paper, makes little comment as to proper style and is not what I'm looking for.

[+70] [2008-09-22 16:19:06] Jough Dempsey

I'll second (or third) " PHP Objects, Patterns, and Practice [1]" by Matt Zandstra (get the newer 3rd edition) as one of the best books on OOP ever, not just on PHP. I recommend it to everyone moving to PHP from another language, or anyone new to OOP.

Another great object-oriented programming reference is Bruce Eckel's " Thinking in Java [2]" which you can download for free on the web. Yes, I know, it's not a PHP book, but most of the same principles apply, and you can translate most of the examples in the book from Java to PHP > 5 in little time since PHP5's object model is so much like Java's (with some interesting differences).


(2) There is actually a 3rd addition coming out soon:… - John Isaacks
(4) Is there a reason why 3rd addition has such low reviews compared to earlier additions on Amazon? Are the older editions better? - JohnMerlino
(7) IMO Experienced C++/C#/Java etc programmers will be better served by a book which focuses on PHP more than OOP concepts. This book was probably intended as an introduction to OOP for procedural PHP programmers. - SDX2000
Hello will these book cover some design techniques about web applications?For example some propper way to design OOP web applications tha will be easy updated ?I am going to buy this book! - nikosdi
[+49] [2008-09-18 10:37:16] David McLaughlin

PHP In Action [1]

Covers pretty much every modern web development topic including:

  1. Object Oriented Programming in PHP (really in depth.. it's like half of the book)
  2. Unit Testing
  3. Refactoring
  4. Web Interfaces - Templating, Smarty, Pure PHP templates
  5. Model View Controller
  6. Input Validation
  7. Handling Database Connections and making them "globally" available in an OOP architecture
  8. Data Class design (for MVC again)

One of the best programming books I've read even though I knew most of that stuff anyway, and I imagine one of the best introductions to OOP for any experienced PHP developer out there wanting to get out of the procedural rut.


(3) DEFINITELY one of the best PHP books. It teaches you much more than just the language, but how to use it like a guru. - CrazyJugglerDrummer
(1) Good book but I'm not sure is ideal for programming newbies. - JDelage
(2) @JDelage: Who said we were looking for books for newbies? :) - Billy ONeal
@Billy ONeat - the OP in his first sentence. - JDelage
(2) @JDelage: Which is followed by "as well as those who have previous programming experience". - Billy ONeal
And then followed by "they don't have to be the same book" :p - Cogicero
[+18] [2008-09-18 09:11:12] Matt Lacey

I'd recommend that every PHP programmer reads Essential PHP Security By Chris Shiflett [1]


why the downvote? - Matt Lacey
Agreed. This book is essential, just as it says. - Mattis
As an introduction to security this book is really awesome. Covers a lot of thing and gives a lot of tips and direction about what to do. - yokoloko
[+14] [2008-09-18 08:48:54] Colonel Sponsz

I like Schlossnagle's Advanced PHP Programming [1]. It's a great reference with good worked examples for things like session handling, RPC, unit testing, caching, profiling and even extending the language engine. If you already know PHP and are using it for a large project it is a very useful book to have around.


[+14] [2011-03-03 14:21:57] Soner Gönül

Here is top List

Developing PHP Applications for IBM Data Servers [1] | IBM Redbooks Published in 2006, 448 pages

  1. Doctrine ORM for PHP [2] Jonathan H. Wage, Konsta Vesterinen | Sensio SA Published in 2010, 373 pages

  2. PHP 5 Power Programming [3] Andi Gutmans, Stig Bakken, Derick Rethans | Prentice Hall PTR Published in 2004, 720 pages

  3. PHP Cookbook [4] Adam Trachtenberg, David Sklar | O'Reilly Media Published in 2006, 810 pages

  4. PHP Essentials [5] | Techotopia Published in 2008

  5. PHP Functions Essential Reference [6] Torben Wilson, Zak Greant, Graeme Merrall, Brett Michlitsch | Sams Published in 2001, 768 pages

  6. PHP Reference: Beginner to Intermediate PHP5 [7] Mario Lurig | Published in 2008, 164 pages

  7. PHP Security Guide [8] | PHP Security Consortium Published in 2005, 37 pages

  8. Practical PHP Programming [9] Paul Hudson | Published in 2007

  9. Practical PHP Testing [10] Giorgio Sironi | Published in 2009, 61 pages

  10. Super Awesome Advanced CakePHP Tips [11] Matt Curry | Published in 2009, 66 pages

  11. The Definitive Guide to symfony [12] Fabien Potencier, Fran�ois Zaninotto | Apress Published in 2007, 425 pages

  12. The Oracle PHP Cookbook [13] John Alphonse, Justin Kestelyn | Oracle Published in 2009

  13. The Underground PHP and Oracle Manual [14] Christopher Jones, Alison Holloway | Oracle Published in 2008, 290 pages

  14. Zend Framework: Surviving The Deep End [15] P�draic Brady | Published in 2009, 37 pages


[+12] [2009-11-13 13:59:56] Sergi

As others said, PHP Objects, Patterns, and Practice (2nd edition) [1] is a good start point if you're developing in PHP, but if you haven't read them, I'll go back to the fundamentals. First Design Patterns: Elements of Reusable Object-Oriented Software [2] by the Gang of Four to learn the common patterns (decorator, composite, facade, singleton...) in software development (some of them are also explained in "PHP Objects..."). Then Patterns of Enterprise Application Architecture [3] by Fowler which extends the basic patterns to create more complex patterns like MVC.

Then you could also take a look to some of Misko Havery videos, like Design Tech Talk Series Presents: OO Design for Testability [4]. He is the Agile Coach at Google and his videos about testing are really illuminating not only in why you should code for testability but also why you should do OOP.

By that moment you will realize that your code is not so good and you'll thing about refactoring. The Refactoring: Improving the Design of Existing Code [5] also by Fowler is considered the bible for refactoring, but I prefer Working Effectively with Legacy Code [6] by Michael Feathers.


[+8] [2008-09-18 08:25:53] David Precious

I've always liked O'Reilly's titles, so I'd recommend their Programming PHP [1] book. It's authored by Rasmus Lerdof, PHP's creator, along with other PHP industry experts, so it could be considered pretty authoritative.


is it still as praised in light of other, newer books? - Beau Martínez
[+8] [2008-09-18 09:15:39] adam

I tend to learn by doing, so I enjoyed the O'Reilly PHP Cookbook [1] and of course the manual (if you download the windows chm, be sure to get the extended version with comments)


Agreed - if you know what you want to do with your site, PHP Cookbook lets you jump directly to code that solves your problem. - John Fiala
(1) @John Fiala but it won't learn you the basics - Abid Omar
[+7] [2008-09-18 09:18:03] Veynom

Personally, I like the SitePoint [1] PHP books. I read them, they are really nice and can be used "out of the box".

And then of course the PHP manuel (mostly for searching for some functions):


[+6] [2008-09-18 18:50:42] Aeon

Larry Ulman's PHP5 Visual QuickPro Guide [1] is what helped me get started in my progress from a hobbyist to a professional developer some eight years back (well, it was an older edition, not this one exactly). You wouldn't expect it from the title, but it's actually well-written, very readable, and very usable for a beginner, without descending into talking-down or dumbing-down the material. Check the amazon reviews for it and subsequent editions.

Looking at publishers, Apress [2] and Pragmatic Programmer [3] books in general are usually pretty good, not to mention O'Reilly [4]. I hear Peachpit Press [5] puts some good quality stuff out too, but I don't have any of their titles, so can't speak with confidence to that.

Oh, and Safari Books [6] has a really cool subscription program where you get unlimited access to a huge number of technical books from O'Reilly and a bunch of other publishers online.


(1) The Visual QuickPro Guide Books are really good. Can't believe no one else thought the same. - The Pixel Developer
[+5] [2008-09-18 15:12:13] thr

This isn't a pure PHP book, but the book that did influence how I write php code the most is "Patterns of Enterprise Application Architecture" by Martin Fowler [1]. It's a nugget of gold for someone that wants to learn to structure and develop object oriented code in a languages such as PHP, Java, C#.


[+4] [2008-09-18 21:50:13] stuart

PHP objects patterns and practice, its the best programming book I ever read.

[+3] [2009-07-17 18:13:08] Ibn Saeed

I would suggest PHP Object-Oriented Solutions by David Powers

PHP Object-Oriented Solutions [1]

* Teaches the fundamentals of OOP (Best Explanation on OOP)
* Simple projects show how OOP concepts work in the real world
* Pre-packaged scripts can easily be added to your own projects

What youll learn

* PHP features, such as the Standard PHP Library (SPL), that are poorly documented or ignored by existing books
* How to develop classes of their own
* OOP in easy-to-understand language without getting bogged down in dense theory
* Solid foundations for developers wishing to delve more deeply into OOP
* How to leverage the strengths of OOP as a means for creating reusable code that can be used successfully within a procedural context
* How to code for both PHP 5 and 6

[+3] [2010-08-23 15:40:46] Bill the Lizard

For absolute beginners I'd recommend Head First PHP & MySQL [1]. It shouldn't be the last PHP book you read if you want to be a professional web developer, but it covers all the basics so it's a good place to start.

One aspect of the book that I really enjoyed was the attention to basic security concerns. It starts off with a very simple site design, then shows how an attacker might exploit the weaknesses of that design and what you can do about it.


[+2] [2008-09-18 10:51:02] Andrew Taylor

Of course it depends on your requirements. If you've gotten to grips with the syntax, and you're looking to develop larger applications, or, you're looking to really harness the OO approach of PHP5, I'd reccomend the Matt Zandstra book: [1]

It really cements the fundamental aspects of application development, and, goes great with the new Zend Framework (which I'd also recommend).



[+2] [2009-06-23 07:38:20] Stefan Gehrig

For an in-depth view on PHP5 I'd recommend (besides the other honorable mentions in this thread):


these 2 books are very handy - tawfekov
[+1] [2008-09-18 09:10:18] Sergei Stolyarov

My choice is It contain very useful user comments on every page. For best practices I recommend read manuals for various PHP frameworks and libraries (like symfony or Propel) because PHP itself is not a “well-formed” language and such great tools will help you to learn best ways of writing of PHP code.

(4) half of the time those user comments are garbage sprinkled with noob - theman_on_vista
but i mean yea, i check the site more then i refer to any 1 php book - theman_on_vista
(2) he said that this isn't what he was looking for. - Mg.
[+1] [2008-09-18 10:22:27] farzad

I think the best book for PHP is "Programming PHP" [1] published by O'Reilly and written by Rasmus Lerdrof. although I liked "PHP & MySQL bible" [2] published by John Wiley, but "Programming PHP" was more effective whilst it had less pages.


[+1] [2011-01-28 21:03:27] JoeyH

I always loved Julie Meloni's books

this was one of the first books on PHP that I actually purchased.. very easy to understand

[0] [2008-09-18 08:42:04] Alister Bulman

For a language reference, it's really hard to beat the website - it's also quite easy to get a local mirror of the relevant manual section for yourself.

Most of the rest of what you need to know is covered by other software engineering texts, like use of testing, or refactoring.

[0] [2008-09-18 09:15:59] Bob Somers

Pro PHP Security [1] is one of the best PHP books I've read in a while.


[0] [2008-09-18 10:45:20] Jon

Personally I hve recently read "Pro PHP: Patterns, Frameworks, Testing and More" by Kevin McArthur (ISBN: 9781590598191). Out this year so pretty up to date. Excellent source of info for those who want to expand their knowledge of PHP.

[0] [2008-09-22 15:54:42] Julian


link text [1]

Or other book by the same author or indeed publisher.


[0] [2009-06-12 12:15:47] Abbas Gadhia

PHP in Action is one book i DONT recommend for someone who wants to learn pure php. Neither does it cover simple php constructs, neither does it cover any advanced topics about php. Anytime you feel that an interesting/advanced topic has started, it stops there and starts off with something else. There is only mention of patterns, OOP concepts, Agile concepts etc etc that you can read off from some book dedicated to the subject.

What a waste of money considering the fact that the last 3 "... in Action" books that i have ready have surely turned out to be the best references on the topic they talk about.

[0] [2009-10-21 18:53:19] Marko

Really different topics of books. I have Programming PHP by Lerdorf which I can say deals with the basics of the language and is propably great if you have to know the language. I wolud recommend for anybody who's not an advanced PHP coder to read Gilmore's Beginning PHP and MySQL from Apress. It has lot's of great content and covers a lot.

[0] [2010-07-20 10:00:04] Alex

I have to say that "Practical Web 2.0 Applications with PHP" was one of the most useful books i ever read. It really improved my skills. [Spam link removed]

[0] [2010-09-03 13:38:10] user439001

A good solid reference manual is a great tool especially if it has practical, real world examples, rather than the sterile classroom ones which don't really match the design you need for your site / app / script. Heres a couple of good ones :

To start with PHP MySQL eBook [1]


[0] [2011-03-21 22:55:31] jasondavis

Core PHP Programming [1] Third Edition for PHP 5
by Leon Atkinson with Zeev Suraski, PHP 5 contributer and Zend Engine 2 co-creator

This is one of my favorite PHP books of all time.


[0] [2011-04-13 08:18:53] nmyster

I learnt all the basics of PHP from a book calld "PHP 5 in easy steps" its a really good, well written beginners guide to getting started and covers the things you got interested in PHP to begin with, such as form processing, sending emails, mySQL, OOP basics and the basics of PHP (and any programming language), arrays, variables, loops etc.

Definatly recommend. I borrowed from a Higher Computing teacher and he never got it back :P

[0] [2011-06-03 10:42:19] Harsh

Read php book written by O'Reilly

Lots of books are there from basics to adnavced like Learning PHP 5, php cookbook etc.. written by O'Reilly

(1) Are you just advertising ? - Desolator
[0] [2011-06-29 01:37:34] Jiego Cordoviz

I think, the most appropriate answer to this totally depends on what stage you are right now on your skill in programming or PHP itself. By the time you get alot of answers, you might just get confused with all the recommendations out there and might not choose anything at all. All books have their own style of writing or atmosphere that affects the readers' absorption of knowledge. So what might be great for one person might be the worst book ever for another. It is highly subjective.

Most times i prefer to learn a language as i develop a project, that way what i read sticks to me for a long time. So in cases like that, it would be better for me to scour google instead of flipping through pages on a book because chances are, what is printed on the book might be deprecated and the delivery was not very clear to the reader.

But anyways, here are some books that i recommend:

  • "About Internet & World Wide Web How to Program" is a good book for beginners, it can give you the starting chops on the language
  • "PHP and MySQL Web Development" is a highly recommended book, you'll refer to it alot i tell you, even when you're a PHP ninja already.

Good times man! Hope you find that book :D