MVC
Micro Framework
Simple, lightweight, PHP MVC micro framework, with more functionalities, e.g. event dispatcher, logger, dependency injection container...
MVC
Directory
For proper functioning of the MVC framework, it is necessary to follow the
following directory structure.
There are 4 subfolders in the src folder:
- controllers - link between database and view, decides what view to display, prepares data
- models - a directory with classes that provide data / possible use of Eloquent ORM
- views - .html, .php, .shtml, ...
- config - configuration files for every package
-
assets
-
config
-
config.json
-
src
-
config
-
mvc.config.json
-
controllers
-
MVC
- MvcController.php
-
models
- Segments.php
-
views
-
MVC
-
EventDispatcher.html
-
MVC.html
-
Template.html
-
vendor
 1$router = new \MVC\Router();
 2
 3$router->addRoute(new \MVC\Route("/", \Controllers\MVC\MvcController::class, "mvc"));
 4
 5return $router;
JSON:
 1"routes": {
 2"/third_parties_components": {
 3"controller": "Controllers\\ThirdPartiesController",
 4"action": "tpc"
 5}
 6},
 7"modules": [
 8"mvc"
 9]
Router
The Router object allows you to easily register all the necessary routes and their
actions from one place.
You can specify module names in the configuration file. The App class then uploads
all registered modules and saves their paths.
Controller
The Controller takes care of calling a specific view and preparing data. User defined Controller must extend the abstract class Controller. Views and Models files can be in model subfolders too, but you must specify a relative address to the view folder.
 1class MvcController extends Controller
 2{
 3public function mvc()
 4{
 5$this->view->render("MVC/MVC.html");
 6}
 7}
Model
To access the database, MVC uses the Micro Framework Eloquent ORM mapping. For more information, see the official Eloquent website.
View
The View part of MVC model implements design pattern Template View. For more informations, click here.
App
You can easily use all the elements of the framework at the same time. Just create a new project, initialize an instance of the App class, and call its run method.
 1$application = new \MMFConfig\Bootstrap();
 2$application->run();