Anatomy of PHP-based CMS

PHP-based content management systems are used in many website projects. A web content management system (CMS) is software which simplifies the task of building web sites that focus on providing information to viewers.
The 3 Tier Architecture
Software can generally be subdivided into the following functional layers:
* Database layer provides access to data that the software manages
* Business layer enforces the business rules that the software implements
* Presentation Layer defines how the user interacts with the software
The physical packaging of the software may or may not reflect these functional divisions. Fully separating them is known as "3 tier" architecture. This approach became the preferred only when advances in communications and software packaging made the division possible and the availability of cheap clients and servers made it practical.
Files and folder
The naming convention can be different but a generic CMS has the following files and folders in their root directory
* models/ or classes/
* library/
* images/
* scripts/
* templates/
* index.php
* config.php
* install.php
The Model/Class folder contains all PHP class files. A typical naming convention might use example.class.php for a class named example. One or more class files can reside here depending on the number of functions the website has. Each class does the transaction with only one MySQL table and there exists at least one class called "database". Other classes interact with database for database transactions.
The library folder has functions to carry out repeated and common tasks. For example, when user fills a web form a validation function is included to check if all fields are correctly entered; after this function return true value, this data is sent to business layer, other example of function can be an email address validation.
Script folder may contain Ajax and JavaScript files and libraries, next template folder has one or more directories inside corresponding to each website layout setting and themes. On the root of the website config files is generated during the installation process, it contains database information and critical website setting any data in this file cannot be altered from usual web interface, install.php file will have an installation form and MySql table structure variables, it generates appropriate error messages and create tables after successfully completing those steps.
Templating system
Html templates also called as themes in some content management systems are the core part in presentation layer. It has one template engine and remaining files necessary to output the layout and styling of web pages these files are template.html, style.css and images directory.
This template.html file has only the layout information and in content area special markups are put for example in content area (article) for left navigation (leftbar) etc. A template engine which could be a PHP class file will find the match for this markups and replace them with respective file output
Installer system
An installation system basically generates two things first one configuration file typically called config.php and second creates database tables, creating database. we need to have basic intelligence built in for example before installation if someone invokes home page of website example.com or example.com/index.php then it must show error message saying that user need to install by clicking this link like example.com/install.php
External pages
*Content Management System using PHP and MySQL
*Development Infrastructure for PHP
*Building CMS installation system
*Simple Web CMS
 
< Prev   Next >