Created
June 2, 2012 03:19
-
-
Save coreymcmahon/2856378 to your computer and use it in GitHub Desktop.
The first version of our front controller for Simplex. - http://www.symfonycentral.com
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 | |
/* Import the autoloader and classes from external namespaces */ | |
require_once __DIR__.'/../src/autoload.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
/* Build the request and response objects using HttpFoundation */ | |
$request = Request::createFromGlobals(); | |
$response = new Response(); | |
/* Create routes... */ | |
$map = array( | |
'/hello' => __DIR__.'/../src/pages/hello.php', | |
'/bye' => __DIR__.'/../src/pages/bye.php', | |
); | |
/* Handle the request and create the response */ | |
$path = $request->getPathInfo(); | |
if (isset($map[$path])) { | |
ob_start(); | |
include $map[$path]; | |
$response->setContent(ob_get_clean()); | |
} else { | |
$response = new Response('Not found', 404); | |
} | |
/* Send the response */ | |
$response->send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment