Skip to content

Instantly share code, notes, and snippets.

@rodrigoSyscop
Last active March 4, 2018 15:08
Show Gist options
  • Save rodrigoSyscop/7d82051bfce3e314ea239533fc3598f9 to your computer and use it in GitHub Desktop.
Save rodrigoSyscop/7d82051bfce3e314ea239533fc3598f9 to your computer and use it in GitHub Desktop.
framework/web/front.php
<?php //framework/web/front.php
require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$request = Request::createFromGlobals();
$map = array(
'/hello' => 'hello',
'/bye' => 'bye',
);
$path = $request->getPathInfo();
if (isset($map[$path])) {
ob_start();
extract($request->query->all(), EXTR_SKIP);
include sprintf(__DIR__.'/../src/pages/%s.php', $map[$path]);
$response = new Response(ob_get_clean());
} else {
$response = new Response('Not Found', 404);
}
$response->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment