A 'light' MVC (model-view-controller) framework for PHP web applications.


Copyright (c) 2012 Tobias Dammers.

Released under a BSD-3 license. Please see the included LICENSE file for


* PHP 5.x, and anything you may need to run it.
* The models use PDO, so if you want to use those, you'll need to have PDO
  support in PHP.
* Apache, with mod_rewrite


Download everything and keep it somewhere convenient.

The mercurial repository is at

If you want to run the examples, you need to create a separate virtual host for
each one, and point the docroot at the /www directory inside the example's 
root dir.


1. Put mvctd.php and the entire /code subdirectory somewhere convenient, but
   outside the docroot.
2. Include mvctd.php from your entry-point PHP script. You probably want to set
   up Apache rewrites that route everything to the same entry point, e.g.
3. In the examples directory, example 1 has a fairly suitable default 
   index.php (examples/ex1/www/index.php) which you can use as a starting
4. If you want to use the Database object, you'll need a configuration
   somewhere that specifies access details for the DBMS. Use the Config::load
   method to provide it as an associative array structure, or
   Config::loadJsonFile to load it from a JSON file.
5. Write some models. Models that inherit from BaseModel provide some basic
   ORM facilities, but you can also use your own models and implement your own
   persistence layer. Note that you'll have to write and maintain the database
   schema yourself and make sure the Model classes match the actual database.
6. Write some controllers and put them into the controller directory configured
   in step 3. All controllers should inherit from BaseController. A typical
   controller will override the process() method to do its thing, set a
   suitable view_name, and populate its view_data. The template engine
   understands data in both associative array and object format, and you can
   freely mix both styles, e.g. an array containing objects of which some
   properties are arrays, etc. Magic __get() properties will also work as
   expected. If you use the default URL mapper, the controller's class name and
   the filename must follow the following convention:
   * the filename uses lower-case with underscores, e.g. foobar_baz.php
   * the controller name must be the same, but in pascal-case, with a
     lower-case 'c' prefixed (for 'controller'): cFoobarBaz.
7. Write some templates and put them into the template directory configured in
   step 3 (assuming you are using the default view engine, which simply loads
   files from a configured directory).