Table of Contents

TinyMVC Framework Online Documentation

Installation

TinyMVC is built with object-oriented PHP 5 and requires PHP 5.1.x or later. To start using TinyMVC Framework download the latest release (see Download section for more details) and unpack somewhere on your web server. It's good practice to keep it outside web browser access area for security issues.

Project Template

Once you have your own copy of TinyMVC framework available, you can move /project_template subfolder somewhere and rename it if you like. This is your main project folder, with appropriate subfolders structure (see next chapter for more details on that). To make TinyMVC up and running simply edit /html/index.php to ensure the path to framework's init.php file is correct.

Check the folowing fragment of code in /html/index.php bootstrap file and set correct path if required:

/**
 * TinyMVC framework init.php file, make sure this path is correct
 */
require_once('../../php-tinymvc/init.php');


Next, point your web browser to /html subfolder, if you can see welcome screen, then installation and configuration process is done and you're ready to using TinyMVC Framework, congratulations! :-)

Note: It might be usefull to set /html folder as your document root directory in web server configuration, there are several ways to achieve this, see your web server documentation for more details

Framework Basic Concept

The main framework concept is consistent with basic Model-View-Controller design pattern, with using TinyMVCFrontController class as front controller responsible for handling all requests, abstract TinyMVCActionController and simple view renderer: TinyMVCViewRenderer class. There are few more classes implemented to cover other importand things, such as exeption handling and configuration management.

Front Controller

Front controller's primary goal is to find out which action controller need to be launched. Each module in the project schould have their own separate controller class named properly, eg: IndexActionController for “index” module (default main module). There are many aproaches to organize project's module structure, it's up to you which one you'll choose.

TinyMVC Front Controller deals with module controllers by analysing two parameters in request:


In other words, example HTTP request like this:

http://www.yourpage.com/index.php?mod=search&act=result


Will launch resultAction() method inside SearchActionController class. Pretty simple, isn't it?

Note: there's no difference between POST and GET type of HTTP request. Both methods are acceptable.

As a result of “Action” method execution, front controller receives TinyMVCModelAndView transfer object which is just simple container for generated “model” and “view”. Once it happens, front controller passes transfer object to view renderer, expeting response code to be returned (eg. HTML page).

User-defined Module Controllers

As metioned above, you need separate action controller (TinyMVCActionController descendant class) for each module and it's up to you how that modules will be organized. Each action for module is handled by separate method.

Simple example of module controller class:

<?php
class IndexActionController extends TinyMVCActionController {
 /**
   * default action method
   */
 public function defaultAction() {
  // action logic here ...
 
  // add elements to model
  $this->model->add('helloMessage', "Hello World!");
 
  // define output view
  $this->view->add('index', 'index.view');
 }   
}
?>

Exception handler

comming soon… ;-)

View Renderer

comming soon… ;-)