Skip to content

ngodinhloc/jennifer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jennifer - A Simple PHP Framework

Jennifer is a simple PHP framework that implements MVC pattern.

Configuration

composer require ngodinhloc/jennifer

Usage

Single Point Entry

index.php

use Jennifer\Http\Response;
use Jennifer\Http\Router;
use Jennifer\Sys\System;

try {
    $system = new System([DOC_ROOT . "/config/env.ini"]);
    $system->setRouter(new Router([DOC_ROOT . "/config/routes.ini"]))->loadView()->renderView();
} catch (Exception $exception) {
    (new Response())->error($exception->getMessage(), $exception->getCode());
}

api/index.php

use Jennifer\Api\Api;
use Jennifer\Http\Response;
use Jennifer\Sys\System;
use thedaysoflife\Api\ServiceMapper;

try {
    $system = new System([DOC_ROOT . "/config/env.ini"]);
    $system->setApi(new Api(new ServiceMapper()))->runAPI();
} catch (Exception $exception) {
    (new Response())->error($exception->getMessage(), $exception->getCode());
}

controllers/index.php

use Jennifer\Http\Response;
use Jennifer\Http\Router;
use Jennifer\Sys\System;

try {
    $system = new System([DOC_ROOT . "/config/env.ini"]);
    $system->setRouter(new Router([DOC_ROOT . "/config/routes.ini"]))->loadController()->runController();
} catch (Exception $exception) {
    (new Response())->error($exception->getMessage(), $exception->getCode());
}

For example of implementation and usage, please take a look at Thedaysoflife project https://github.com/ngodinhloc/thedaysoflife.com which was developed using Jennifer framework