$injectionParams = (require_once "injectionParams.php"); // Contains helper functions for the application. require_once "appFunctions.php"; require_once "routes.php"; if (strcasecmp(PHP_SAPI, 'cli') === 0) { $request = new CLIRequest('/cleanupException', 'example.com'); } else { $request = HTTPFunction::createRequestFromGlobals(); } // Create the first Tier that needs to be run. $routingExecutable = new Executable(['Tier\\Bridge\\FastRouter', 'routeRequest'], null, null, 'Room11\\HTTP\\Body'); // Create the Tier application $injector = new Injector(); /** @var $injectionParams \Tier\InjectionParams */ $injectionParams->addToInjector($injector); $app = new TierHTTPApp($injector); // Make the body that is generated be shared by TierApp $app->addExpectedProduct('Room11\\HTTP\\Body'); define('TIER_ROUTING', 10); define('TIER_GENERATE_RESPONSE', 10); define('TIER_BEFORE_SEND', 80); define('TIER_SEND', 90); $app->addExecutable(TIER_GENERATE_RESPONSE, $routingExecutable); $app->addExecutable(TIER_SEND, ['Tier\\HTTPFunction', 'sendBodyResponse']); try { // Run it $app->execute($request); } catch (\Exception $e) { $body = new TextBody("Exception: '" . $e->getMessage() . "'", 500); HTTPFunction::sendRawBodyResponse($body); }