private function bindRouterRequest(Request $request) { // $this->container->set($request); $router = $this->container->get('routing.router'); if ($request->get->has('path')) { $request->setAttributes($router->match($request->get->get('path'))); } else { $request->setAttributes($router->match('/')); } }
public function getController(Request $request) { if (!($controller = $request->attributes->get('controller'))) { return false; } $callable = $this->createController($controller); if (!is_callable($callable)) { throw new \Exception(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request->getPathInfo())); } return $callable; }
public function __construct(Request $request = null) { if (null === $request) { $this->mode = 'CLI'; $request = Request::create($this->mode); } if (!$this->isBooted) { $this->boot($request); } }
<?php use Syph\Http\Http; use Syph\AppBuilder\AppBuilder; use Syph\Http\Base\Request; $env = (include_once '../bootstrap.php'); require_once __DIR__ . '/../app/AppKernel.php'; $request = Request::create(); define('BASE_URL', $request->getBaseUrl()); $app = new AppKernel($env, $request); $response = $app->handleRequest(new AppBuilder()); try { echo $response; } catch (Exception $e) { echo $e->getMessage(); }
public function __construct(Request $request) { $this->basePath = str_replace('index.php', '', $_SERVER['SCRIPT_FILENAME']); $this->baseUrl = $request->getBaseUrl(); }