You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Timothy Warren 685c5e8db0 Update Query 11 years ago
app Update Query 11 years ago
assets Update Query 11 years ago
docs Overhaul back to php 5.3 Remove redundant class structure 11 years ago
sys Update Query 11 years ago
tests Formatting cleanup 11 years ago
.gitignore Fix tests 11 years ago
.gitmodules Remove extra files 11 years ago
README.md Overhaul back to php 5.3 Remove redundant class structure 11 years ago
index.php Formatting cleanup 11 years ago
phpdoc.dist.xml Update docs 11 years ago

README.md

miniMVC

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

Requirements

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

Unique features

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

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

Database connections are set in /app/config/db.php

File Structure

  • index.php - framework bootstrap

  • app - configuration and app-wide files

    • classes - helper classes
    • config - configuration files
    • modules - MVC triads
      • controllers - controller classes
      • models - model classes
      • views - module-specific views
    • views - global page templates
      • errors - error page templates
  • assets - frontend files

    • js - javascript files
    • css - css files
    • config - minifier configuration files
  • sys - core framework classes

Common Tasks

  • Creating a controller

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

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

    $this->db = miniMVC\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) - creates an instance of that model as a member of the current class. After loading the model, you can call its methods like so

    $this->[model name]->method()

  • Loading a class

    Librarys / classes found in app/classes or sys/libraries are autoloaded. To call a library, simply instantiate that class.

    Classes with a get_instance static methods should be called like so:

    $obj =& miniMVC\class::get_instance()

    Other classes should be called using the new operator

    $obj = new miniMVC\class()