PHP

Python

Javascript

Verilog

This mvc framework was built up from a tutorial I found at phpro.org. It serves to separate the data models, the application control logic, and view logic presented to the user. This separation allows for such things as easier implementaion, portability, and better testability to name a few.

The index.php file(along with the Apache .htaccess file) provides a single point of entry to the framework. This file creates a single instance of the registry which is passed as a parameter to other blocks within the framework as well as instatiating the application logic and loading the controller.


<?php
 session_start
();
 
ob_start();

 
/*** error reporting on ***/
 
error_reporting(E_ALL);

 
/*** Set site root (css, img  tags) relative to htdocs ***/
 
$work_dir    = (basename(dirname(dirname(dirname(__FILE__)))));
 
$project_dir = (basename((dirname(dirname(__FILE__)))));
 
$site_dir    = (basename(((dirname(__FILE__)))));
 
$site_root   '/';
 
define ('__SITE_ROOT'$site_root);

 
/*** define the site path ***/
 
$site_path realpath(dirname(__FILE__));
 
define ('__SITE_PATH'$site_path);

 
/*** project specific CONSTANTS    ***/

 /*** define access level constants.    ***/
 
define ('__ADMIN_ACCESS' '9');

 
/*** define PageNavigator constants.    ***/
 
define("PERPAGE"4);
 
define("OFFSET""offset");
 

 
/*** include initialization file     ***/
 /*** contains controller_base, registry, router, template, db(singleton)    ***/
 
include 'includes/init.php';

 
/*** create registry object ***/
 
$registry = new registry;

 
/*** create singleton database object in registry ***/
 
$registry->db db::getInstance();

 
/*** load router    ***/
 
$registry->router = new router($registry);

 
/*** load template     ***/
 
$registry->template = new template($registry);

 
/*** set controller path ***/
 
$registry->router->setPath (__SITE_PATH '/controller');

 
/*** load controller ***/
 
$registry->router->loader();

 
ob_end_flush();
?>