コード例 #1
0
ファイル: IntegrationTest.php プロジェクト: atawsports2/Tier
 public function testExecutableOrder()
 {
     // Create the Tier application
     $app = new TierHTTPApp($this->injectionParams);
     $callCount = 0;
     $fn = function ($stage, $expectedCallCount, $returnValue) use(&$callCount) {
         return function () use(&$callCount, $stage, $expectedCallCount, $returnValue) {
             if ($callCount !== $expectedCallCount) {
                 throw new \Exception("Wrong call count for {$stage}");
             }
             $callCount++;
             return $returnValue;
         };
     };
     $app->addInitialExecutable($fn('Initial', 0, TierApp::PROCESS_CONTINUE));
     $app->addBeforeGenerateBodyExecutable($fn('BeforeGenerate', 1, TierApp::PROCESS_CONTINUE));
     $app->addGenerateBodyExecutable($fn('GenerateBody', 2, TierApp::PROCESS_CONTINUE));
     $app->addAfterGenerateBodyExecutable($fn('AfterGenerateBody', 3, TierApp::PROCESS_CONTINUE));
     $app->addBeforeGenerateResponseExecutable($fn('BeforeGenerate', 4, TierApp::PROCESS_CONTINUE));
     $app->addGenerateResponseExecutable($fn('GenerateResponse', 5, TierApp::PROCESS_CONTINUE));
     $app->addAfterGenerateResponseExecutable($fn('AfterGenerate', 6, TierApp::PROCESS_CONTINUE));
     $app->addBeforeSendExecutable($fn('BeforeSend', 7, TierApp::PROCESS_CONTINUE));
     $app->addSendExecutable($fn('Send', 8, TierApp::PROCESS_CONTINUE));
     $app->addAfterSendExecutable($fn('After', 9, TierApp::PROCESS_END));
     $request = new CLIRequest('/', "example.com");
     $app->execute($request);
 }
コード例 #2
0
ファイル: index.php プロジェクト: danack/imagick-demos
// current directory is the root of the project
chdir(realpath(__DIR__) . '/../imagick');
$injector = new Injector();
// Read application standard config params
$standardInjectionParams = (require "injectionParams.php");
/** @var $injectionParams \Tier\InjectionParams */
$standardInjectionParams->addToInjector($injector);
// Read application HTTP config params
$httpIinjectionParams = (require "httpInjectionParams.php");
/** @var $httpIinjectionParams \Tier\InjectionParams */
$httpIinjectionParams->addToInjector($injector);
if (strcasecmp(PHP_SAPI, 'cli') == 0) {
    // We only reach CLI here when we are testing, so hard-coded to test particular
    // route.
    $request = new CLIRequest('/image/Imagick/deskewImage', 'phpimagick.com');
} else {
    $request = HTTPFunction::createRequestFromGlobals();
}
// Create the first Tier that needs to be run.
$routeRequest = new Executable(['Tier\\Bridge\\FastRouter', 'routeRequest']);
// Create the Tier application
$app = new TierHTTPApp($injector);
$app->createStandardExceptionResolver();
// Make the body that is generated be shared by TierApp
$app->addExpectedProduct('Room11\\HTTP\\Body');
$app->addInitialExecutable(['ImagickDemo\\AppTimer', 'timerStart']);
$app->addGenerateBodyExecutable($routeRequest);
$app->addAfterSendExecutable(['ImagickDemo\\AppTimer', 'timerEnd']);
$app->addSendExecutable(new Executable(['Tier\\HTTPFunction', 'sendBodyResponse']));
// Run it
$app->execute($request);
コード例 #3
0
ファイル: index.php プロジェクト: atawsports2/Tier
<?php

use Tier\Executable;
use Tier\Tier;
use Tier\TierHTTPApp;
use Room11\HTTP\Request\CLIRequest;
ini_set('display_errors', 'on');
$autoloader = (require __DIR__ . '/../../../vendor/autoload.php');
Tier::setupErrorHandlers();
ini_set('display_errors', 'off');
// Read application config params
$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 = Tier::createRequestFromGlobals();
}
// Create the first Tier that needs to be run.
$routingExecutable = new Executable(['Tier\\JigBridge\\Router', 'routeRequest'], null, null, 'Room11\\HTTP\\Body');
// Create the Tier application
$app = new TierHTTPApp($injectionParams);
// Make the body that is generated be shared by TierApp
$app->addExpectedProduct('Room11\\HTTP\\Body');
$app->addGenerateBodyExecutable($routingExecutable);
$app->addSendExecutable(['Tier\\Tier', 'sendBodyResponse']);
$app->createStandardExceptionResolver();
// Run it
$app->execute($request);