PHP (LAMP) Content Management System

PHP (LAMP) Content Management System

Published on

Back in 2003 WordPress would not exist for another 8 years. It was obvious to everyone that building websites was painful. Anyone could use Dreamweaver or FrontPage to build static html pages and upload them to a website, but there were many drawbacks.

  • Inconsistancy - It was difficult to get a consistent layout between pages. It was common for menus not to match between web pages.
  • Software Required - Customers usually needed to own and learn FrontPage or Dreamweaver.

Something was needed, but what? Enter server-side programming. PHP popped up about this time to fill in the gap. It was easy to learn, flexible and fast.

I started experimenting with building my own system. My final design was fast, light and powerful. WordPress and other CMS are powerful but I have yet to see one which is as fast and light.

Design & Philosophy

Most systems start with a philosophy or design concept. Sometimes it's a great idea. Sometimes it's a disaster.

My idea was to take the category structure which I used in building inventory control systems (like ARAMARK's ACTFAS system) and use it's hierarchy to build content.

Epiphany

This actually made a great deal of sense, for a number of reasons.

  • Categories are hierarchical.
  • The browser renders pages based on the DOM, which is hierarchical.
  • Therefore the structures should be compatible.

Categories

The second insight is that most catalog websites (with a shopping cart) already have large category tree-like structures. The website itself could be viewed as an extension of that hierarchy.

How about Layout?

It occured to me that layout, or how a page is drawn, could be based on the category we are in. If you are in the "catalog" then we draw products. If we are in "Articles" then we draw a layout fitting for articles.

The power of inheritance

Another design feature which I have found very useful in my applications is the concept of inheritance. It is amazingly powerful. By default things work one way but when you change an ancestor all children of that structure change their behavior.

Putting it together

Now I put these concepts together and what I built was a CMS system where:

  • Speed was king! I always optimized for Speed
  • Category was always calculated for the current category
  • The category information on all parent categories were also always calculated with speed in mind
  • This category information tells the system exactly how to draw everything!

Blocks - Taking it up a knotch

So now the engine was fast and well designed. But how to implement it?

I build a system of block which could be assigned to a category or an article.

A set of blocks belonging to an article creates a layout. This could be assigned to any category.

Inheritance means once a layout was assigned all categories under that category knew their layout and could draw themselves.

This system worked in milliseconds and was lightining fast.

Further Optimization

  • Styling and Javascript was appended to each page dynamically.
  • Styling and Javascript optimization and compression was built in.
  • Image optimization was built in, including automatic sizing and caching.
  • Built-in security sanitizes all variables automatically.

Final results

  • Final speeds show page renders with data as fast as 23 milliseconds:

If you think that's fast check out the results with caching:

It's faster because MySQL/PHP remembers the queries involved and can spit out an answer that much faster.

So you might wonder how fast can this run without any data, just fetching the category structure, template, render the blocks involved, compress the CSS and Javascript and send back the web page?

That's right. 4ms. Take that WordPress!

Conclusion

LAMP architecture is amazing. The system I built is amazing. But it had two fatal flaws.

  • LAMP architecture is not the future - JAMstack is!
  • I'm just one programmer. This project was too big for one programmer.

Nonetheless a few customers still use it and their websites run faster than any WordPress websites.