Core for Cherry-project

v1.6.1 2019-05-11 19:17 UTC

This package is auto-updated.

Last update: 2022-05-12 02:09:44 UTC


README

The Cherry-project Core

GitHub license

GitHub release

Packagist Version

This is core for Cherry-Project that contains Cherry Request, Response, Router, and Templater.

In root of your application you must define main file and call application Core Kernel and Router classes:

require_once __DIR__ . '/../vendor/autoload.php';

use Cherry\Routing\Router;

$kernel = new Cherry\Kernel(__DIR__);

$router = new Router();

Kernel class takes only one argument - your application root path.

With main file you mast have directories config, controllers, templates:

root
└─ config/
└─ controllers/
└─ templates/

Config

config directory is a 'home' for application config and router files:

config/
└─ config.json
└─ routes.json

config.json contains application environmental parameters:

{
  "ROUTES_FILE":      "path-to-routes.json",
  "CONTROLLERS_PATH": "path-to-controllers-directory",
  "TEMPLATES_PATH":   "path-to-templates-directory",
  "LOGS_PATH":        "path-to-logs-directory"
}

Controller

Controller is a simple PHP class that contains public methods mapped on route:

"action": "DefaultController::index"

Every method returns Cherry\HttpUtils\Response object.

$this->render('index');

2019 © Cherry-project