Skip to content
integry edited this page Aug 25, 2011 · 5 revisions

Integry Framework is an MVC framework, which means that it follows the classic separation of concerns established by the MVC pattern. To reitarate, the logic of MVC applications is separated in 3 parts:

  • Model - handles business logic, often represents data objects (ORM classes, etc). The majority of code usually goes here.
  • View - visual output, in our case the View represents page templates
  • Controller - holds the 2 above pieces together. To put it simply, Controllers read data from Models and pass it to Views for rendering.

Integry Framework is not actually concerned regarding the Model part, you can use your ORM of choice or construct the Models in any other way that suits your requirements. We do recommend trying our ActiveRecord library however.

Controllers and Views are the two important pieces of applications, that our framework provides infrastructure for. Controllers are PHP classes that contain one or more methods. All public methods are considered actions. To put it simply, each action is a particular type of page of your application. A quick example:

<?php

class IndexController extends Controller
{
    public function index()
    {
        return new ActionResponse('who', 'World');
    }

    public function json()
    {
        return new JSONResponse(array('msg' => 'Hello, World!'));
    }
}

?>

As you see, the controller actions do not output anything directly (echo calls, etc.) or even refer to particular template files. Instead every action returns a Response object, which tells application what to do next (render a template, return JSON data, redirect, etc.). There are several types of responses (and you can add your own).

IF prefers convention over configuration, so all controller actions that should generate rendered output (HTML, etc.) already have the respective view template files mapped. From the example above, the index/index action returns an ActionResponse object. This means that application should render a template using the supplied data. The template is automatically referenced by index/index, so the template file path would be /application/view/index/index.php

Clone this wiki locally