Sunday, May 27, 2012

What is the best PHP programming book?

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.

Source: Tips4all


  1. I'll second (or third) "PHP Objects, Patterns, and Practice" 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" 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. PHP In Action

    Covers pretty much every modern web development topic including:

    Object Oriented Programming in PHP (really
    in depth.. it's like half of the
    Unit Testing
    Web Interfaces - Templating, Smarty,
    Pure PHP templates
    Model View Controller
    Input Validation
    Handling Database Connections and
    making them "globally" available in
    an OOP architecture
    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. I'd recommend that every PHP programmer reads Essential PHP Security By Chris Shiflett

  4. I like Schlossnagle's Advanced PHP Programming. 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.

  5. As others said, PHP Objects, Patterns, and Practice (2nd edition) 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 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 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
    . 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 also by Fowler is considered the bible for refactoring, but I prefer Working Effectively with Legacy Code by Michael Feathers.

  6. Here is top List

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

    Doctrine ORM for PHP
    Jonathan H. Wage, Konsta Vesterinen | Sensio SA
    Published in 2010, 373 pages
    PHP 5 Power Programming
    Andi Gutmans, Stig Bakken, Derick Rethans | Prentice Hall PTR
    Published in 2004, 720 pages
    PHP Cookbook
    Adam Trachtenberg, David Sklar | O'Reilly Media
    Published in 2006, 810 pages
    PHP Essentials
    | Techotopia
    Published in 2008
    PHP Functions Essential Reference
    Torben Wilson, Zak Greant, Graeme Merrall, Brett Michlitsch | Sams
    Published in 2001, 768 pages
    PHP Reference: Beginner to Intermediate PHP5
    Mario Lurig |
    Published in 2008, 164 pages
    PHP Security Guide
    | PHP Security Consortium
    Published in 2005, 37 pages
    Practical PHP Programming
    Paul Hudson |
    Published in 2007
    Practical PHP Testing
    Giorgio Sironi |
    Published in 2009, 61 pages
    Super Awesome Advanced CakePHP Tips
    Matt Curry |
    Published in 2009, 66 pages
    The Definitive Guide to symfony
    Fabien Potencier, Fran�ois Zaninotto | Apress
    Published in 2007, 425 pages
    The Oracle PHP Cookbook
    John Alphonse, Justin Kestelyn | Oracle
    Published in 2009
    The Underground PHP and Oracle Manual
    Christopher Jones, Alison Holloway | Oracle
    Published in 2008, 290 pages
    Zend Framework: Surviving The Deep End
    P�draic Brady |
    Published in 2009, 37 pages

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

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

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

    Build Your Own Database Driven Website Using PHP & MySQL, 3rd ed.
    The PHP Anthology (Volume I & II)
    The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition

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

    PHP Manual

  10. Larry Ulman's PHP5 Visual QuickPro Guide 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 and Pragmatic Programmer books in general are usually pretty good, not to mention O'Reilly. I hear Peachpit Press 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 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.

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

  12. 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. 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#.

  13. I would suggest PHP Object-Oriented Solutions by David Powers

    PHP Object-Oriented Solutions

    * 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

  14. For absolute beginners I'd recommend Head First PHP & MySQL. 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.

  15. 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:

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


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

    PHP 5 Power-Programming from Andi Gutmans, Stig Sæther Bakken and Derick Rethans
    Zend PHP 5 Certification Study Guide from Davey Shafik and Ben Ramsey

  17. 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.

  18. I always loved Julie Meloni's books

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

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

  20. 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.

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

  22. 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.

  23. Try

    link text

    Or other book by the same author or indeed publisher.

  24. 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.

  25. 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.

  26. 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]

  27. 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

  28. Core PHP Programming 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.

  29. 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

  30. 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