Go to file
Timothy Warren 4da0123985 Move code out of src folder 2012-04-30 16:33:48 -04:00
app Move code out of src folder 2012-04-30 16:33:48 -04:00
assets Move code out of src folder 2012-04-30 16:33:48 -04:00
docs Move code out of src folder 2012-04-30 16:33:48 -04:00
modules/welcome Move code out of src folder 2012-04-30 16:33:48 -04:00
sys Move code out of src folder 2012-04-30 16:33:48 -04:00
tests Reorganize class hierarchy 2012-04-27 16:28:25 -04:00
README.md Various improvements - db needs fixing though 2012-04-26 16:26:50 -04:00
index.php Move code out of src folder 2012-04-30 16:33:48 -04:00
phpdoc.dist.xml Move code out of src folder 2012-04-30 16:33:48 -04:00

README.md

miniMVC

miniMVC is a minimalistic Modular MVC framework, with built-in minifier, and pure-PHP templating system.

Requirements

  • PHP 5.4+
  • PDO extensions for databases you wish to use
  • Webserver that correctly handles PATH_INFO, such as:
    • Apache
    • IIS
    • Lighttpd
  • SimpleTest library for running unit tests

Unique features

Extensive use of PHP's magic methods on the base class

  • __toString() method allows a view of the current class object when the current class object is used as a string. If you prefer var_dump() or var_export(), you can pass the name of that function if you call the __toString method directly.

    Eg. $this . "string", $this->__toString(), echo $this;

  • __call() method allows (in PHP 5.3+) the dynamic addition of callable closure objects

    Eg. $this->foo = function($baz){} is callable as $this->foo(), with the current object as the last argument

Database class is an extension of PHP's PDO class.

Database class uses Query as a database abstraction layer and query builder.

File Structure

  • index.php - framework frontend

  • app - configuration and app-wide files

    • config - configuration files
    • errors - error page templates
    • views - global page templates
  • assets - frontend files

    • js - javascript files
    • css - css files
    • config - minifier configuration files
  • modules - MVC triads

    • controllers - controller classes
    • models - model classes
    • views - module-specific views
  • sys - core framework classes

Common Tasks

  • Creating a controller

      <?php 
      class Foo extends MM_Controller {
    
      	function __construct()
      	{
      		parent::__construct();
      	}
      }
    
  • Creating a model

      <?php
      class Bar extends MM_Model {
    
      	function __construct()
      	{
      		parent::__construct();
      	}
      }
    
  • Loading a database

    $this->db = db::get_instance($db_name);

    Note that multiple databases can be used in the same class by specifying a different database name.

  • Loading a model (From a controller)

    $this->load_model($model)