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-07-03 13:33:36 -04:00
* PHP 5.3+
2012-01-17 11:55:42 -05:00
* PDO extensions for databases you wish to use
2012-07-03 13:33:36 -04:00
* Webserver that correctly handles PATH_INFO, such as:
2012-01-17 11:55:42 -05:00
* Apache
* IIS
* Lighttpd
2012-07-03 13:33:36 -04:00
* Resin/Quercus
2012-01-17 11:55:42 -05:00
* SimpleTest library for running unit tests
2011-12-30 17:43:53 -05:00
### Unique features
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
2012-04-26 16:26:50 -04:00
Database class uses [Query ](https://github.com/aviat4ion/Query ) as a database abstraction layer and query builder.
2011-12-30 17:09:29 -05:00
2012-04-30 16:52:38 -04:00
Database connections are set in /app/config/db.php
2011-12-30 17:43:53 -05:00
### File Structure
2011-12-30 17:09:29 -05:00
2012-05-14 16:52:05 -04:00
* index.php - framework bootstrap
2011-12-30 17:09:29 -05:00
2011-12-30 17:43:53 -05:00
* app - configuration and app-wide files
2012-05-03 16:07:40 -04:00
* classes - helper classes
2011-12-30 17:43:53 -05:00
* config - configuration files
2012-05-03 16:07:40 -04:00
* modules - MVC triads
* controllers - controller classes
* models - model classes
* views - module-specific views
2011-12-30 17:43:53 -05:00
* views - global page templates
2012-05-14 16:52:05 -04:00
* errors - error 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
2012-01-09 10:59:02 -05:00
* sys - core framework classes
### Common Tasks
* Creating a controller
< ?php
2012-05-22 11:11:36 -04:00
class Foo extends miniMVC\Controller {
2012-01-09 10:59:02 -05:00
function __construct()
{
parent::__construct();
}
}
* Creating a model
< ?php
2012-05-22 11:11:36 -04:00
class Bar extends miniMVC\Model {
2012-01-09 10:59:02 -05:00
function __construct()
{
parent::__construct();
}
}
2012-01-17 11:55:42 -05:00
* Loading a database
2012-01-09 10:59:02 -05:00
2012-05-22 11:11:36 -04:00
`$this->db = miniMVC\db::get_instance($db_name);`
2012-01-09 10:59:02 -05:00
Note that multiple databases can be used in the same class
by specifying a different database name.
* Loading a model (From a controller)
2012-05-03 16:07:40 -04:00
`$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
2012-05-15 10:27:34 -04:00
2012-05-21 14:29:36 -04:00
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:
2012-05-22 11:11:36 -04:00
`$obj =& miniMVC\class::get_instance()`
2012-05-21 14:29:36 -04:00
Other classes should be called using the new operator
2012-05-22 11:11:36 -04:00
`$obj = new miniMVC\class()`
2012-05-03 16:07:40 -04:00
2012-05-21 14:29:36 -04:00