use Chalk\Frontend; use Chalk\Frontend\UrlResolver as FrontendUrlResolver; use Chalk\HookManager; use Chalk\Parser; use Coast\Controller; use Coast\Request; use Coast\Response; use Coast\Router; use Coast\Url; use Coast\UrlResolver; use Coast\View; $app = (new Chalk(__DIR__, $config->envs))->param('root', $app)->param('config', $config); $app->param('em', $app->lazy('app/init/em.php'))->param('cache', $app->lazy('app/init/cache.php'))->param('swift', $app->lazy('app/init/swift.php'))->param('hook', new HookManager())->param('session', $app->config->session)->module(new Core()); $app->load('app/init/funcs.php'); File::baseDir($config->publicDataDir->dir('file')); File::mimeTypes($app->load('app/init/mime-types.php')); Toast\Wrapper::$chalk = $app; Toast\Wrapper::$timezone = $app->config->timezone; $app->param('backend', $app->lazy(function ($vars) { $app = $vars['app']; $backend = (new Backend(__DIR__, $app->config->envs))->param('chalk', $app)->param('frontend', $app->frontend)->param('session', $app->session); $backend->param('view', new BackendView())->param('parser', new Parser(['isTidy' => true]))->param('notify', new Notifier())->param('controller', new Controller())->param('router', new Router(['target' => $backend->controller, 'params' => ['module' => 'core']]))->param('url', new UrlResolver(['baseUrl' => new Url("{$app->config->backendBaseUrl}"), 'baseDir' => $backend->dir('public'), 'router' => $backend->router]))->param('image', $backend->load('app/init/image.php'))->param('hook', new HookManager())->param('em', $app->em)->param('cache', $app->cache)->param('swift', $app->swift)->failureHandler(function (Request $req, Response $res) { return $res->status(404)->html($this->view->render('error/not-found', ['req' => $req, 'res' => $res], 'core')); })->errorHandler(function (Request $req, Response $res, Exception $e) { if ($this->chalk->isDebug()) { throw $e; } return $res->status(500)->html($this->view->render('error/index', ['req' => $req, 'res' => $res, 'e' => $e], 'core')); }); $backend->executable($backend->image); $backend->executable($backend->router);