HomePHP Page 2 - Building a Site Engine with PHP, Part 1
First Things First - PHP
Content management systems are becoming very popular, but what if you took it a step further than that? That’s exactly what I plan to show you how to do in this series of articles. I’m going to explain how to build a site engine. A site engine is a core code base and database that can run multiple sites that are completely different while all running in unison, using all the same code, yet separate from each other.
The best thing to do first, I say, is to get out some paper and one of those sticks that write stuff.... Oh, yeah, a pencil! Then literally draw out a diagram of your plan on coding. No need for a bunch of words, just horribly sketched boxes and lines, labeled with each elements name. I decided that I would need to first create, in order, the following things for my site engine:
Database
Main index page
Plug-in system
Module system (plug-ins for the plug-ins)
Content blocks
So, trying to stay advanced, I grabbed my $5 mechanical pencil, and I sketched it out like this:
Pretty isn't it? Basically, what I have here is my index page calls the database, selects all the plug-ins that are initialized for the specific site, then the plug-ins select all the modules that at initialized for the selected plug-ins. Then the modules select all the content blocks that are initialized for the selected modules with a few more parameters checked, such as authentication level and specific page. Then it's all returned to the index page to form the website. This diagram is an easier read.
Index >--call plug-ins--> Loaded Plug-ins >--call modules--> Loaded modules >--call block--> Loaded blocks >--return data--> Index displays data
This has shown to be a very solid method of doing a plug-in system, due to the fact that if a plug-in isn't loaded the content block that depends on that certain plug-in won't load and cause nasty errors. Now that the plug-ins have been briefly described, I'll talk about the authentication and block systems.