Last active
March 4, 2018 15:08
-
-
Save rodrigoSyscop/7d82051bfce3e314ea239533fc3598f9 to your computer and use it in GitHub Desktop.
framework/web/front.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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