Weblogs: Book Reviews
Reviewing books about web and computer related books
Monday, October 19, 2009
Symfony 1.3 Web Application Development
Title: Symfony 1.3 Web Application Development (on Amazon.co.uk)
Authors: Tim Bowler, Wojciech Bancer
Publisher: Packt Press
Publish Date: September 2009
Disclaimer: I received a review copy of this book from Packt Publishing in September 2009.
Symfony is a PHP5 framework for rapidly building dynamic web applications. This book is targeted at Symfony 1.3 when it hits production-ready status. At the time of writing the 1.3 version is still in alpha. Unfortunately this book suffers from the uncertainly as final decisions haven't been made. The major one is whether the default ORM will be Propel or Doctrine. The book flip-flops on which one is the default ORM. On the whole the book feels like a rushed job, trying to get to market before Symfony 1.3 hits production ready.
The Symfony project themselves have useful introductions to using Symfony, most particularly their Jobeet tutorial which covers Symfony through the practical development of a Job listing site. This new book by Packt attempts the same approach, building a website for a chain of milkshake restaurants. It is a decent example that covers many of the features of Symfony, and so comparing it to the Jobeet tutorial is a useful exercise.
The intended audience for this book are developers using older versions of Symfony as well as developers new to Symfony. I'm fairly new to Symfony and I've been developing with it for almost a year now.
Overview of the book
The first chapter of Symfony 1.3 Web Application Development covers getting and setting up Symfony. The next chapter sets out the skeleton of our application by defining the database schema, routing, actions and templates. This is followed by a chapter on adding business logic to to model and adding navigation. A chapter on building a simple form to email module takes us through Symfony Forms, and then takes us through converting it into a reusable plugin.
Then we create the administration interface through chapter 5, customising the admin screens as well as locking parts down through authentication. Chapter 6 covers adding Javascript to the admin interface by adding an image uploading widget, a date picker and rich text editing.
Chapter 7 shows off some of Symfony's internationalisation and localisation features. There follows a chapter on adding 3rd party libraries to symfony, and a useful chapter on various caching layers in Symfony. The final chapter talks about deploying your application to a production environment.
Building the skeleton of the application
The chapter on setting up Symfony and creating the skeleton of the application competes directly with the Jobeet tutorial, and unfortunately comes off second best. The approach the book takes to installing Symfony is to grab the current version from the Symfony SVN repository and then create a sandbox using that code. This is different to the preferred Symfony 1.2 method of doing an SVN checkout to the lib/vendor
directory of each project.
What I found bizarre was the authors' preference for using the Propel XML schema format for defining the database instead of Symfony's consistent YAML methods. The authors state that they find YAML more difficult to read and with spaces instead of tabs this causes problems with large YAML files such as a database schema. I find this puzzling since all of Symfony's configuration is done with YAML, so it's impossible to avoid - the authors later have to teach the reader how to do YAML anyway, so introducing the XML way is just not efficient.
And introducing the XML vocabulary they don't. There's two pages of database schema in XML format, and they explain just 4 attributes of the entire document. No mention is made of the structure, or the purpose of the elements, let alone the various field types that are allowed. The whole XML way of defining a database schema looks left as an exercise for the reader.
The HTML in the code examples left me horrified. Essentially the page layout template is a set of div
s with inline style attributes. Including the 5 item navigation list, each li
having the same three lines of inline style properties. I'm astonished that in the 21st century we have such a poor understanding of CSS from people teaching development on the Web. Jobeet beats the pants off this section of the book by embracing the customisability and flexibility of CSS by creating a competition for skinning their application - that's perfect web standards evangelism. This Packt Press book however, shows a lack of modern web development techniques that have been prevalent over at least the last four years.
The attention to detail is lacking. There's no mention of how to configure the web server to serve content from the web directory. Considering that the book heavily uses the custom domain milkshake, leaving out the web server configuration is a disservice to the reader, since they can't really follow along with the book. Again, this seems to be another exercise for the reader with no clear guidance given of what needs doing. A passing mention of aliasing the Symfony assets directory is the closest the book comes to the web server configuration. Jobeet covers this particularly well in day one of their tutorial.
Dealing with business logic
The chapters covering adding in more complicated business logic are better, they feel that they hold together better than the previous chapters. It takes the reader through creating new modules and adding in custom logic, as well as getting hold of request-related information. The routing sections are decently explained. Particularly the explanation of pagination and partials were well written.
The next chapter on creating a newsletter signup script, so taking a form, adding the received data to a database and firing off an email is a good chapter, the plugin section being extremely useful. It introduces the Symfony Forms feature as we build the module from a database schema and generate the form classes before customising them in both the structure of the form and how it is rendered on screen.
As an accessibility practitioner, I'm noticing that there's no mention of explicit HTML label
s and grouping by fieldset
s, and the error handling on form validation leaves little to be desired. Still, it sounds like that these renderers can be rewritten to produce accessible markup.
Security is covered by the vaguest wave to a CSRF token (Cross Site Request Forgery), and that this hidden input field code snippet helps prevent this. Honestly, that is the coverage of security in its entirety. I understand that this book isn't about teaching security to web developers. The Jobeet tutorial is slightly better in this regard, but not by much.
There's no detail on where or how to use third party libraries involved in email delivery. The code example assumes that the library is already installed at the correct location and ready to be used.
The section of creating a plugin is perhaps the most useful section, taking the reader through the steps of creating a reusable plugin for modules. Perfect for isolating bits of code to use in other projects. The higher level process is easy to understand, but the actual implementation is under a cloud because of the setup concerns of the first chapter. I hope the actual step-by-step process is correct, and that really means this book needs to be properly tech-edited and proof-read by a hands on developer.
Configuring the Administration area
I struggled getting the admin area working through the Jobeet tutorial, so I'm happy to say that the process of customising the administration configuration makes a lot more sense after reading this chapter. Particularly, I found the Jobeet process of locking down access to the adminstration side of the application made even the login page requiring authentication before being accessed (possibly I needed to clear the cache?). This book makes a more determined effort to explain how the authentication system works and how it is configured, so that fills me with more confidence.
The chapter on enhancing forms with Ajax came as a surprise as they added the functionality to the adminstration area instead of a simple form outside. That shows the confidence of the author to pull this off. I hope it works.
Internationalisation
It's another useful chapter, this time on internationalising the application. The chapter takes the reader through extending the database schema to handle translations of each piece of content, and the changes needed to address the model to reflect the selected locale (the authors use the term 'culture' for locale).
For localising the templates and interface text the book steps through using XLIFF (XML Localisation Interchange File Format) which takes a text string as a key and returns a translation that's stores in the XML translation files. There are automated tools to extract existing text from templates to populate the initial files. And then filtering all static text through a special filter function produces the correct translations.
However, after being through an internationalisation hell for the latter half of 2008, I realise the book isn't anywhere near complete in it's internationalisation coverage. There's no mention of handling static text that contains request-variable information, like This is page 6 of 12
, nor any mention of Symfony's ordinal and plural grouping of numbers which impressed me in its ability to handle Polish. Nor was there any mention of currency, number or date formatting.
Granted that translating plain text is a major step forward for being able to localise sites, but it's one step in a series of steps. (This is despite the code examples containing mojibake, presumably because the printing process of the book is at fault here)
Extending Symfony, Performance and Deployment
This chapter covers using other PHP5 libraries inside of Symfony. The demonstration of using ez Component's Pie Chart component inside a Symfony application impressed me, and again demonstrates the confidence of the authors. Unfortunately the followup about integrating Zend framework components is two paragraphs and feels completely unfinished.
The performance chapter covers the various cache levels of Symfony. Right from configuring gzip encoding within symfony, to template cache and data caches, and even when to avoid using the ORM when raw performance is necessary. The step by step guide is very useful, as we watch the load times of the page shrink drastically.
The chapter on deployment covers how to disable a Symfony application, enable outage messages, and then recommends using rsync to migrate code from the development environment to production. It's a very quick overview of rsync.
Conclusion
There is a fair amount of useful information in this book. I will be using it's plugins and administration chapters again fairly soon. But this book suffers badly, it really needs a solid technical review and a very sharp editor review. It needs a proper developer test - take a developer who has no knowledge of Symfony and get them to follow along with the book.
One serious issue was the Finishing off the location page
section of Chapter 3 is supposed to cover adding in vacancies on the page, which is assumed to be there in Chapter 5's Handling foreign keys using admin generator
.
My gripe against the use of XML will be alleviated by either explaining the XML syntax of the database schema, or switch back to YAML. (But it would also help having a typesetting review of the book, the indenting of the code examples - including the YAML code snippets - aren't correct or consistent.)
To be honest, I would wait for the second edition of this book; and only if it's strictly tech-edited, sternly proofread and typeset reviewed, after the first release of Symfony 1.3. It can be quite a good companion book to the Symfony framework, it's just not ready yet. When it is, it will be a useful guide to Symfony 1.3
Older Posts:
- [23/02/2009] Restful PHP Web Services
- [03/05/2006] Cascading Style Sheets: The Designer's Edge by Molly Holzschlag
- [02/04/2006] Color for Websites by Molly Holzschlag
- [23/06/2003] Cascading Style Sheets: Separating Content from Presentation
- [19/05/2003] Building Accessible Websites
[ Weblog | Categories and feeds | 2011 | 2010 | 2009 | 2008 | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 ]