public static function invoke($app_class, $app_root_dir, $env)
{
$app = new $app_class($app_root_dir, $env);
$dispatcher = new static($app);
$dispatcher->boot();
try {
$response = $dispatcher->handleRequest();
} catch (\Exception $e) {
// Please handle errors occurred on executing Dispatcher::handleError with your web server.
// Dietcube doesn't care these errors.
$response = $dispatcher->handleError($e);
}
}
<?php namespace { require_once __DIR__ . '/../vendor/autoload.php'; use Pimple\Container; class Application extends \Dietcube\Application { public function config(Container $c) { } } class Route implements \Dietcube\RouteInterface { public function definition(Container $c) { return [['GET', '/', 'Example::hello']]; } } } namespace Controller { class ExampleController extends \Dietcube\Controller { public function hello() { return 'hello world'; } } } namespace { \Dietcube\Dispatcher::invoke('Application', __DIR__ . '/..', 'development'); }