Building a content management system can seem like a daunting task to the novice PHP developer. However, it needn’t be that difficult. In this tutorial I’ll show you how to build a basic, but fully functional, CMS from scratch in just a few hours. Yes, it can be done!
Along the way, you’ll learn how to create MySQL databases and tables; how to work with PHP objects, constants, includes, sessions, and other features; how to separate business logic from presentation; how to make your PHP code more secure, and much more!
Before you begin, check out the finished product by clicking the View Demo button above. (For security reasons this demo is read-only, so you can’t add, change or delete articles.) You can also click the Download Code button above to download the complete PHP code for the CMS, so you can run it on your own server.
For this tutorial, you’ll need to have the Apache web server with PHP installed, as well as the MySQL database server running on your computer. Setting all this up is beyond the scope of the tutorial, but a really easy way to do it is simply to install XAMPP on your computer.
The feature list
Our first job is to work out exactly what we want our CMS to do. The CMS will have the following features:
The homepage, listing the 5 most recent articles
The article listing page, listing all articles
The “view article” page, letting visitors see a single article
List all articles
Add a new article
Edit an existing article
Delete an existing article
Each article will have an associated headline, summary, and publication date.