Skip

PHP Book that teaches how to build a small CMS?
May 1, 2009 9:29 AM   Subscribe

Good PHP book that walks you through the building of a basic PHP/MySQL content management system?

It's can be PHP 4 or 5 based. The content management system does not have to be super-complex. I realize there are lots of open source options out there, but I want to learn to create a small one from scratch that I can build on.
posted by zobot to Technology (9 answers total) 17 users marked this as a favorite
 


Using one of the many application frameworks (e,g, CodeIgniter) is a good idea if you're constructing a CMS. Frameworks have their drawbacks (speed mainly), but they'll save you a ton of work.
posted by le morte de bea arthur at 9:45 AM on May 1, 2009


...not that that's strictly an answer to your question, but this is the kind of task frameworks are made for, and a book that teaches you to code a CMS in raw PHP may be more of an educational exercise than a practical one.
posted by le morte de bea arthur at 9:51 AM on May 1, 2009


Seconding Web Database Applications with PHP & MySQL. It's what I learned on, and it'll give you everything you need.

The only downside is that its examples use the HTML_Template_IT templating system, which is no longer an active PEAR project. It's still a fine templating system to learn on, but be prepared to switch to something more production-ready, like Smarty, when you actually start building your system.

If you aren't familiar with the basics, I'd recommend against using a framework. Frameworks are great when you understand what steps they let you skip, but if you don't, you can run into big time-eating problems when things go wrong.
posted by DrJohnEvans at 10:31 AM on May 1, 2009


There's so many CMSes in PHP these days, it's not worth rolling your own. Learn how to use one of the ones that already exists.
posted by SpecialK at 10:37 AM on May 1, 2009


I'm going to have to disagree with SpecialK; if you are new to PHP/MySQL, building a CMS is probably the best way to learn. And even if you aren't, sometimes it's just better to start from scratch to build what you want, rather than going nuts trying to hack some existing CMS to suit your needs.

And I will second everything DrJohnEvans said. Don't try to use a framework until you know the basics, and you probably want to use Smarty or something like it for templating. Smarty's easy to figure out and will allow you to avoid a lot of headaches down the road.
posted by subclub at 11:53 AM on May 1, 2009


I agree with subclub. It can definitely be a very useful learning experience to build one from scratch as long as you're conscious of the fact that you are re-inventing the wheel.

It also might make sense to design a custom low-capability one for a very niche purpose especially if it's done in a clean and content-portable way. But once you find yourself considering adding things like history versioning, caching, workflow, access control lists and permission systems, et cetera, it just isn't worth it to start from scratch on that stuff; scrap your custom system and re-engineer around an OTS product. If you're using a vendor like the Drupal Project that has an automated way to notify you of security patches it's worth it for that alone.

Just a related heads up, one of the fine character-building and skill-building aspects of rolling your own CMS is that you often learn quite alot about security engineering and SQL injection and things when your site gets hacked and vandalized (hopefully visibly, if it isn't instead just silently taken over by a bot farmer needing hosting space or a relay.) So definitely have a logging system built in and monitor that, your web server logs, and your server OS system and security logs. And if you have a site with lots of traffic and a reputation to preserve there's XSS to be aware of.

Another option that should generally noted on a discussion of this topic is that there is a midldle road through the CMS sub-genre of the content repository like Apache Jackrabbit (Java in that case, not PHP, but you might want to build your PHP site in something like Quercus or Phalanger to keep your platform options open) that provides some of the abstract content management capabilities and leaves it up to you to build the front end however you desire.

There are products like Jackrabbit specifically designed for that usage but also with almost any CMS product, if you really want to you can rip its guts out and use them separately from the rest of it, so you're just essentially utilizing the user interface for editing and other purposes and your web site code is directly hitting the database or other data store to retrieve the content. Though any vendor will scream in horror at the thought of you doing this, then calm down when they realize it means you've voided your warranty and they get to ask for more money before giving you specialized tech support.

Also, if you're up for some really hard-core skill building, I would say that the real way to go these days is to build the user interface entirely on the client side with a javascript platform like dojo or MochiKit or YUI or even better, drool, one of the vector graphics packages like dojox.gfx or Raphaƫl, and have the server-side code mostly accessed by something along the lines of REST services..
posted by XMLicious at 1:11 PM on May 1, 2009


Thirding subclub. I would never, EVER want to deploy a homegrown CMS these days. However, building one is an important learning experience and will help you better understand the compromises and decisions that went into other systems and frameworks.
posted by verb at 2:12 PM on May 2, 2009


Thanks for all the advice, especially subclub and XMLicious. I was still hoping to get book recommendations though, as that was my original question.
posted by zobot at 1:21 PM on May 4, 2009


« Older I run a Slowdance Night every ...   |  How can I get my Apple iPhone/... Newer »
This thread is closed to new comments.


Post