Book Review: PHP5 CMS Framework Development by Martin Brampton

PHP5 CMS Framework Development (published by packt publishing) is a a book that offers "Expert insight and practical guidance to creating an efficient, flexible, and robust framework for a PHP5 based content management system." Upon reading through the book I have found that it gives an excellent case study of Martin Brampton’s approach to CMS design and implementation. Brampton has been very active in the PHP CMS scene for several years working on widely known projects such as Mambo and Joomla. He is also the creator of Aliro, a newer CMS that had the purpose of utilizing more of the object oriented abilities of PHP5. His experience designing and developing Aliro influenced much of this book.

One might be concerned that the ideas in this book are slanted towards how Brampton decided to implement various aspects of Aliro. While it is true that much of the book uses code directly out of Aliro, I feel that he did take the time to make sure he explained the reasons for the design and development decisions he made. This is the feeling that brings me to the overall conclusion that this book is ultimately an in depth case study of the design of Aliro. If you are interested in developing your own CMS framework or have already developed a framework that you would like to extend, then I would highly recommend this book. Even if you do not agree with all of the concepts and ideas presented it does a fantastic job at pointing out potential pitfalls and other items to consider as you work on your CMS.

After the jump I give a chapter by chapter breakdown of the book.

The book begins with a general description of what Brampton deems as
generic features of a CMS. He takes time to discuss both what he
considers critical features (user management, access control, security
and extensibility) and what he considers to be "desirable" features:
(performance, database abstraction, menuing, and
internationalization/localization.) He then goes on to make a good case
for why PHP 5 should be used. In some senses I find it disheartening
that after several years we are still trying to sell PHP 5 but this is
certainly not Brampton’s fault. He also briefly addresses some basic
best practices for php development. Some of the ideas he presents in
this chapter I do not completely agree with. The promotion of
singletons is something that always disheartens me as I am still
convinced that they are heavily overused in the programming world.
Brampton also promotes the use of HEREDOCS which I have grown to
dislike for mostly stylistic reasons. He does however make excellent
point about the importance of considering certain patterns for use in
development with particular attention towards the MVC pattern.

giving a one chapter intro to the basics of CMS design Brampton dives
into studies of various, common aspects of CMS systems. I appreciate
the basic organization of each of these sections. Each chapter starts
off briefly describing a common problem. Then a more detailed analysis
of the problem commences covering various aspects of the problem domain
to consider. After presenting various view points and ideas he
concludes the chapter with the solution he chose. The solutions are
detailed at a very low level including both code and often a database
schema as well. Great care is taken to ensure that the solution
addresses in some form or another each aspect of the problem. The
beauty of this organization is that it allows you to more easily use
this book as a reference when you do hit a road block. It offers the
ability to get another opinion and more ideas on the problem you are
trying to solve.

In chapter two Brampton begins addressing the
various aspects of CMS frameworks in more detail. This chapter deals
with user management in a CMS. It covers several different areas of
user management including storing and securing user data,
authenticating users, as well as allowing for the extending of user
data. This is one of the areas of the book that is useful even to those
that are not creating a broad CMS framework. User management and
authentication are an aspect of most every system now. There are
several ideas that I gleaned from this chapter. One of the ideas that I
had not really put any consideration towards was initially brought up
in chapter one and expounded on in this chapter. The idea was
separating administrator login from regular user login. The purpose
given was to allow for more restrictive measures to be put into place
to give a greater level of security to critical settings. I knew this
was a common aspect of many, many systems but until this point I had
never seen a clear, precise reason for doing so. I also appreciate the
fact that he pointed out table indexing as something that is to be
considered early in the design process. Indexing is something that
often gets overlooked in these kinds of books and as someone who is
routinely addressing database performance in his every day job I love
to database performance getting emphasis.

The placement of the
chapter three is somewhat of an enigma to me. Chapter three details
Brampton’s ideas for code organization. This is such a foundational
concept of any system. It makes much more sense to me to have this
content as chapter two. Nothing in this chapter is very dependent on
what anything in the previous chapter. I like how he advocated the use
of an auto loader to bring code in the system. He made his arguments
with three very good points: code is loaded in the fewest places
possible, knowledge of whether or not code is already loaded is
irrelevant, and only the code that is used is loaded. I do not fully
agree with how he created his auto loader. I prefer to use pear
standards with file names to allow fully implicit mapping of requested
classes to files. He also gives further credence to the singleton
pattern which again, I am not a personal fan of. I can detail the
reasons in a later post.

After the brief segue into code
organization we get back to users and sessions in chapter four. In this
chapter Brampton discusses why sessions are important and various
security pitfalls related to sessions to avoid. In some senses this is
a fairly basic chapter as sessions are a concept that is not at all
specific to CMS frameworks and as result there is allot of information
that many of you may already know. However, the fact that such
attention is given to sessions again adds value outside of the pure CMS
realm to this book. One topic that it brought up that I have seen
neglected in other books is search engine bots. The concern that is
raised is performance related as bots could cause potentially hundreds
of new sessions to be started which could be taxing on your session
store. This is not something I have ran into myself as my work is
mostly on closed systems. So it was a somewhat interesting piece of

In chapter five Brampton discusses interaction with the
database. The first portion of the chapter talks about the benefits of
relational databases, touches on caching, persistent connections,
prepared statements, and several other basic considerations you must
make when working with a database. The concept of abstracting the
database is discussed as is data objects, security, and error handling.
One thing I don’t really care for in this chapter is that he seems to
shun prepared statements as something that is only useful if you are
going to run the same query multiple times with the reasoning that they
are more laborious to implement. I am not sure why he feels that they
are laborious but to each their own I suppose. He did counter this
however by providing some alternatives to the security benefits of
prepared statements including escaping characters past to the often
overlooked LIKE function in SQL to prevent wild card searches happening
that are not intended.

Chapter six moves on from discussing
database to talking about access control. A very good overview of how
to implement a role-based access control system is given. In a fashion
similar to chapter two Brampton outlines how he has implemented access
control using code and database schema examples. A large emphasis is
placed on caching which in my opinion is a critical part of access
control as it is one of the most used components in any given CMS

In chapter seven Brampton begins to discuss how to
handle extensions. The opening sentence in this chapter is, "Now we
have reached a critical point in our book." I agree, extensibility is
generally what will separate a good CMS from a great CMS. There are
three different types of extension discussed: templates, modules, and
components. There is a wealth of information, ideas, and concepts in
this chapter. In the solution portion of this chapter he details how he
has built his extension framework by taking advantage of the object
oriented capabilities of PHP 5. While I think he does a good job laying
down a basic foundation of concepts I wish he made use of actual
interfaces for components and modules. Overall this is one of the
chapters where you are almost certain to develop some ideas of how his
work can translate into your software.

Of all the chapters in
the book chapter 8 is the one that I feel could be more in depth.
Caching in my opinion is a very important part of a CMS as it is going
to be one of the first and easiest ways to increase performance. There
was not allot of talk about centralized caching via a system like
memcache and there was nothing mentioned of prefetching as an
alternative to caching. He did detail some good reasoning about why you
want to cache your XHTML (not everything has to be 100% dynamic) and he
also briefly touched on centralized caching, I just don’t think it was
given enough attention.

Chapter nine deals with menus. Like the
other feature specific chapters it includes schema and code samples.
Menus are a concept that is in my opinion hard to discuss in a such a
way that you can describe a generalized implementation. If you are
looking for help with ways to deal with menus and you don’t
particularly care for how Brampton works with them then I would
encourage you to at least try to look at his recommendations from a
philosophical standpoint as once again I think he does give reasons for
why he does things in certain ways.

Chapter ten was a very
interesting chapter to read. In this chapter Brampton discusses
internationalization. In both my career and personal life,
internationalization is not something I have really needed to work
with. That being said, one of my first open source projects was
enabling internationalization in Zen Track. It was very enlightening
to read through this chapter and then look back at at how I did things.
Had I read through this chapter and seen the discussion about gettext I
would have been much better off. Internationalization is one of those
concepts that seems to be harder to describe than it is to show code so
the examples in this section wind up being incredibly simple.

eleven gives a very good overview of some of the different approaches
you can take towards display. I think Brampton does an outstanding job
of reassuring readers that you cannot create a solid argument for any
one of the various display methods being better in every situation for
every group of developer. Each has strengths and weaknesses that must
be considered with the needs of the system developers and users kept in
mind. He also brings up some outstanding points about WYSIWYG editors
in CMSes and ways to cope with some of the problems that they introduce.

twelve is titled ‘Other Services’ and really winds up being that
‘miscellaneous’ for several common aspects of CMS frameworks that are
important but not hard to discuss. Among some of the concepts discussed
are XML parsing, configuration, more WYSIWYG editing, file and
directory handling, and email. Code examples are given for each of
these ‘services’

Chapter thirteen covers error handling. This is
a fairly straight forward concept and this chapter does a good job at
briefly covering different types of errors and gives you viable
strategies for handling them. Due to the simplicity of the subject the
chapter is incredibly short.

The final chapter of the book
focuses on how to manage the various types of content one would want to
store in a CMS. Several different content types are discussed. Ideas
for content organization, tagging, handling comments, and even dealing
with media is covered here.

Overall, I found this book to be
much more interesting then I would have imagined from the title. I am
not someone that routinely deals with CMS frameworks and I really don’t
have any desire to write my own but I was still able to find a wealth
of information and ideas that I can easily apply to the software that I
do write. It is not really an exhaustive reference or review for any
single aspect of CMS development but it gives you a fantastic overview
of many different areas and can be used as a springboard to launch you
into the areas that you find most interesting.

I do think there
could be some improvement in the layout and structure of the book. It
would have felt more natural if the generic concepts such as code
organization, databases, and caching were handled first and then
specific features were looked at. There were also a few off-the-cuff
remarks and descriptions that are not entirely accurate. If you
overlook those and focus on the meat of the book though I think it is a
useful book.

6 thoughts on “Book Review: PHP5 CMS Framework Development by Martin Brampton”

  1. Thanks for your post on this book. Seems like one I should check out.

    I wanted to ask about your dotProject i18n work. I’m part of the current development team and was wondering when you had done that work and if it had ever made it back into the core. If it hasn’t been sent “upstream,” I’d be happy to take a look at it for consideration. If it’s already the i18n code I’m familiar with, then “thank you” for your work on it.

    I’d love to hear more thoughts of how you’d like to have done better–if you would change things now after reading this book.

  2. There is a correction to make, I am actually not sure why I said dotProject. It was ZenTracker that I did that work on. I apologize for the confusion. and I think I worked on it around 5 or 6 years ago? I can’t seem to find the project anymore so it may very well be a dead project.

    I will correct the article. I’m very glad you asked this question :).

  3. I guess it is called Zen Track:

    Now that everyone realizes my memory sucks, thanks for the comment :).

    I will see about putting aside some time to detail what I would do differently as it would be an interesting introspect for myself.

  4. Thank you for your kind review of my book on building CMS frameworks in PHP5. I’m happy to agree with much of what you say, and the rest is really a matter of legitimate differences of opinion. Having said that, one thing I’m interested to take up is the use of singleton classes. While I can see that they have drawbacks, my feeling is that they are the least bad option in a number of cases, on account of limitations of the PHP object model. In particular, the use of class methods (which might be seen as a natural alternative to singletons) is quite constrained by the characteristics of static methods. Some relevant discussions appear in my article on so-called peer classes in Propel and Symfony at

Leave a Reply

Your email address will not be published. Required fields are marked *