2011-12-30 17:09:29 -05:00
# miniMVC
miniMVC is a minimalistic Modular MVC framework, with built-in minifier, and pure-PHP templating system.
2012-01-17 11:55:42 -05:00
### Requirements
2012-04-05 12:48:10 -04:00
* PHP 5.4+
2012-01-17 11:55:42 -05:00
* 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
2011-12-30 17:43:53 -05:00
### 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` ;
2011-12-30 17:09:29 -05:00
2011-12-30 17:43:53 -05:00
* `__call()` method allows (in PHP 5.3+) the dynamic addition of callable closure objects
2011-12-30 17:09:29 -05:00
2011-12-30 17:43:53 -05:00
Eg. `$this->foo = function($baz){}` is callable as `$this->foo()` , with the current object as the last argument
2011-12-30 17:09:29 -05:00
2012-01-17 11:55:42 -05:00
#### Database class is an extension of PHP's PDO class.
2011-12-30 17:09:29 -05:00
2011-12-30 17:43:53 -05:00
* miniMVC supports any database supported by PDO
* Database class also implements the `__toString` method
2011-12-30 17:09:29 -05:00
2011-12-30 17:43:53 -05:00
### File Structure
2011-12-30 17:09:29 -05:00
2011-12-30 17:43:53 -05:00
* index.php - framework frontend
2011-12-30 17:09:29 -05:00
2011-12-30 17:43:53 -05:00
* app - configuration and app-wide files
* config - configuration files
* errors - error page templates
* views - global page templates
2011-12-27 13:30:44 -05:00
2011-12-30 17:43:53 -05:00
* 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
2012-01-09 10:59:02 -05:00
* 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();
}
}
2012-01-17 11:55:42 -05:00
* Loading a database
2012-01-09 10:59:02 -05:00
`$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)
2012-01-17 11:55:42 -05:00
`$this->load_model($model)`