Skip to main content

MVC Architecture

The basic architecture of n2n is MVC (Model, View, Controller). We cannot present the whole concept here, but we would like to show you how a request is processed with the MVC architecture of n2n.

Invocation of the Controller​

The redirect rule in the .htaccess ensures that every request to our framework runs through public/index.php. The index.php adds the directories app, lib and var to the include_path. After that n2n creates a Controlling Plan.

The Controlling Plan compares the requested path with the application configuration (var/etc/app.ini) and the module configurations. It then decides which controller is invoked for processing the request.

Controllers can be nested. This means that the invoked controller can delegate the processing to another controller.

Process Within a Controller​

The invoked controller decides which action method is responsible and calls it. The action method loads the required models to process data and then decides which view must be invoked to build the response.

Attention

n2n is able to return different views. The most common type are HTML views. But there are various other view types. You can also create your own view types!

The controller should pass all required building blocks to the view so that the view no longer has to worry about logic. A view can call other views for assembling the output. For example by using a template or importing other views. The output generated this way is passed to the web server to be returned.

You can find more detailed information in our Quickstart.