Directory structure

MVC design pattern

Ubiquity implements MVC2 design pattern.
The directory structure makes it easy to separate views, models and controllers.
 ├ cache
 ├ config
 ├ controllers
 ├ models
 └ views
namespace controllers;
class Main extends ControllerBase{
	 * @route("index","methods"=>["get","post"])
	public function index(){
Controllers & routes

Pretty URLs

Ubiquity uses pretty URLs, built from the principle controller/action/{parameters...}.
It is also possible to use the @route annotations.
Models & ORM


Models are Plain Old PHP Objects, only with members and accessors to them.
Object relational mapping relies on member annotations.
A Data Access Layer (DAO class) performs bidirectional transfer of data between the relational database and the domain layer (models).
namespace models;
class Product{
	 * @id
	 * @column("name"=>"id","dbType"=>"int(11)")
	private $id;

	 * @column("name"=>"name","dbType"=>"varchar(65)")
	private $name;
$product=new Product();
class Products extends ControllerBase{

	public function index(){
{% extends "base.html" %}
{% block body %}
	{{ message }}
{% endblock %}
View loading & Twig templating


Views are loaded from the controller, in a classic way.
The controller optionally pass them the data.

Twig is the default template engine.

Classes autoloading

Ubiquity use PSR-4 composer autoloader.
The root namespace of a project is anchored in the app/ folder.
namespace controllers;
class Product{
 └ controllers 
      └ Product.php

     class IndexController extends ControllerBase{
             public function isValid($action){
                     return USession::exists('activeUser');

             public function onInvalidControl(){

Access control

Access control to a controller can be performed using the isValid and onInvalidControl methods.