/** * @return $this */ public function createDependencies() { $dependency = new FactoryDefault(); $dependency->set('db', function () { return $this->getDatabase(); }); $dependency->set('router', function () { $router = new Router(false); $routes = Routes::get(); foreach ($routes as $group => $controllers) { foreach ($controllers as $controller) { $router->add($controller['route'], ['namespace' => "App\\Controllers\\{$group}", 'controller' => $controller['class'], 'action' => 'run'], $controller['method']); } } $router->notFound(['namespace' => 'PhRest\\Controllers', 'controller' => 'Missing', 'action' => 'run']); return $router; }); $dependency->set('view', function () { return new View(); }, true); $this->setDI($dependency); return $this; }
<?php require dirname(__DIR__) . '/config/bootstrap.php'; $request = new \nx\core\Request(); $dispatcher = new \nx\core\Dispatcher(); $dispatcher->handle($request, \app\config\Routes::get_routes());