Monthly Archives: April 2011

PHP Framework – Day 1

Start of simple, start off clean.

I am going to assume a few things in these posts,
PHP 5.2 or above. ( 5.3 is better )
mySQL is our database of choice.
You understand the basics of setting up a virtual host/development area, and setting up your database.

Setting up your index file.

The ‘index.php’ is going to handle all requests. We will define the necessary contacts and then call out bootstrap file which starts and loads all of our needed classes.

from there, we load our bootstrap file that loads all needed classes.

The Core::Router() function does the routing.
The router function will check based on the 1st and 2nd segment to see if a matching view exists and then parse that view in to the main template file.

Download the source files and have a look trough, I have commented most functions, Follow trough from the index file and follow the includes.

There is no use of the database or sessions yet so just drop this on your web server and run it.

[download id="12"]

Beginners Guide to PHP Happiness.

Lately I have been seeing some nastiness being taught to a group of Junior web developers.
It comprises of maxing all sorts of nasty combinations of mixing your PHP, HTML, classes, queries and stand alone functions into an unorganised pile of mess.

Developing any project, simple of complex in this manor will very quickly become a nightmare, to me, and more so to those student developers.

I am going to put together a series of quick and simple posts to make a clean, simple and effective PHP based framework to act as a learning step for these students.