cherry-project / core
Core for Cherry-project
v1.6.1
2019-05-11 19:17 UTC
Requires
- php: >=5.6.0
- ext-json: *
- cherry-project/router: 1.1.*
- cherry-project/templater: 1.1.*
This package is auto-updated.
Last update: 2024-11-12 07:39:35 UTC
README
The Cherry-project Core
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