Esempio n. 1
0
try {
    $dotenv = new Dotenv\Dotenv(realpath(__DIR__ . '/..'));
    $dotenv->load();
} catch (InvalidArgumentException $exception) {
}
// Bootstrap
require_once 'Doozr/Bootstrap.php';
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Relay\Runner;
// Build queue for running middleware through relay
$queue[] = function (Request $request, Response $response, callable $next) {
    // Boot the App kernel
    $app = Doozr_Kernel_App::boot(DOOZR_APP_ENVIRONMENT, DOOZR_RUNTIME_ENVIRONMENT, DOOZR_UNIX, DOOZR_DEBUGGING, DOOZR_CACHING, DOOZR_CACHING_CONTAINER, DOOZR_LOGGING, DOOZR_PROFILING, DOOZR_APP_ROOT, DOOZR_APP_NAMESPACE, DOOZR_DIRECTORY_TEMP, DOOZR_DOCUMENT_ROOT, DOOZR_NAMESPACE, DOOZR_NAMESPACE_FLAT);
    // Invoke Middleware
    return $app($request, $response, $next);
};
// Create a Relay Runner instance ...
$runner = new Runner($queue);
// ... and run it with the queue defined above
$response = $runner(new Doozr_Request_Web(new Doozr_Request_State()), new Doozr_Response_Web(new Doozr_Response_State()));
// Stop profiler & save data
$profilerData = uprofiler_disable();
$profiler = new uprofilerRuns_Default();
$profiler->save_run($profilerData, DOOZR_NAMESPACE_FLAT);
// After running the whole queue send the response (HTTP way)
$responseSender = new Doozr_Response_Sender_Web($response);
$responseSender->send();
/*
 * If you want to call normal files within this directory feel free to :)
 */
<?php

if (is_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $_SERVER['SCRIPT_NAME']) && '.php' !== strtolower(substr($_SERVER['SCRIPT_NAME'], -4))) {
    return false;
}
if (!isset($_SERVER['REQUEST_URI']) || 0 === strpos($_SERVER['REQUEST_URI'], '/xhprof')) {
    return false;
}
register_shutdown_function(function () {
    $xhprof_data = uprofiler_disable();
    if (null === $xhprof_data) {
        return;
    }
    $xhprof_runs = new uprofilerRuns_Default();
    $xhprof_runs->save_run($xhprof_data, $app);
});
uprofiler_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);