Book Review: RESTful PHP
, by Samisa Abeysinghe.
When I received and unpacked the book, it was a little lighter than I had expected, however REST really isn’t rocket science and can easily be covered in a tome this size. Overall it was well-written (with only as many spelling mistakes as any other PHP book) and clearly organised. The author begins by skating over why we don’t want to use SOAP, and shows his enthusiasm for REST as a replacement. However before the true elegance and concepts of REST are brought out and revered, we skip straight along and start to look at examples. Very few services that claim to be RESTful actually are, which makes writing anything along these lines very tricky, however I did feel the author could have been clearer about why having a single URL and a parameter for which action should be performed, doesn’t fit well. We do get a sense of excitement about services as ways to “glue together” bits of data on the net, and the possibilities of exposing and consuming information in this way.
Technical Content
Several frameworks are mentioned that can be used with REST, I’ve only heard of one (Zend Framework) – and this book works through a number of examples of working with Zend Framework to provide a REST service. The examples throughout are very thorough – starting with designing the service and getting the semantics of HTTP verbs sensibly applied. We are then taken through building the service using Zend Framework, creating a library class of functionality and then setting up the server to respond to incoming requests. For anyone using this book it is also worth checking for more up to date tutorials; Zend Framework has regular releases and some of the information in the book is already out of date – the dangers of the cutting edge!
Excess Baggage
On a personal level I’m not a big fan of frameworks; Zend Framework is a favourite but the use of it in this setting means that there is a large amount of the book dedicated to Zend Framework, the MVC pattern, and other things that aren’t really anything to do with REST. Call me old-fashioned but for me RESTful services need only HTTP and a data format of some kind, JSON or XML, and a good understanding of the grammar and structure of something that “smells” RESTful. In this book I got bogged down in the cookbook-style examples and lost sight of the bigger picture. The chapter summaries and best practice pointers though were great and I hope readers do take note of these.
Overview
If you need to build a RESTful service and you don’t mind Zend Framework, then this book will attempt to guide you through the process and explain plenty of useful stuff along the way. For a mid-level PHP programmer coming in to services for the first time, I consider this book a nice entry point. However if you were hoping to pick up the concepts behind RESTful services and look to apply them in your own work, then your $40 would be better spent on the RESTful Web Services from O’Reilly – you won’t be copying and pasting working PHP code, but you will come away with some great ideas.
I agree with your issues about some of the book turning into a mini ZF tutorial book.
I feel that lately a lot of space has been wasted on PHP books re-explaining MVC concepts, THEN introducing ZF (or another framework). Chalk it up to publishers not wanting to assume everyone reading the book is up to date on OOP patterns (ignoring how long MVC has been mainstream).
Maybe a good alternative, since frameworks are a big buzz word right now and probably guarentee extra sales for publishers, is all of the book do “from scratch” examples and spend a final chapter or appendix on “oh and it can be so much easier if you’re starting a project from scratch, check out this short ZF example”. Might even be able to sell a book structure like that by saying you’ll not alienate the developer crowd that is maintaining or extending an existing codebase that can’t just be scratched and ported to a framework.
Plus you learn better when you do it from scratch and really handle the guts…
Daniel: I completely agree. I do like and use Zend Framework, but I already have books about it. When I buy a book on a subject, I don’t really want lots of ZF content. I can only assume that because its seen as a “buzz word”, people feel the need to include it in any books current being written, and I hope this trend will soon be reversed.
If you’re really interested in creating a RESTful application in PHP, you might want to consider checking out Konstrukt, http://www.konstrukt.dk
hey thxs for the tip…using it now works nicely.