Created
October 7, 2015 06:41
-
-
Save chriseskow/2711290009738004f6e7 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/* | |
composer.json: | |
{ | |
"require": { | |
"slim/slim": "^3.0@RC", | |
"zendframework/zend-diactoros": "^1.1", | |
"symfony/http-foundation": "^2.7" | |
} | |
} | |
*/ | |
require 'vendor/autoload.php'; | |
function test($message, $value) { | |
printf("%-35s%s\n", $message, $value); | |
} | |
test('$_SERVER["REQUEST_URI"]', $_SERVER['REQUEST_URI']); | |
test('$_SERVER["SCRIPT_NAME"]', $_SERVER['SCRIPT_NAME']); | |
test('$_SERVER["PATH_INFO"]', $_SERVER['PATH_INFO']); | |
test('$_SERVER["PHP_SELF"]', $_SERVER['PHP_SELF']); | |
$e = new Slim\Http\Environment($_SERVER); | |
$r = Slim\Http\Request::createFromEnvironment($e); | |
test('Slim getBasePath()', $r->getUri()->getBasePath()); | |
test('Slim getPath()', $r->getUri()->getPath()); | |
$r = Zend\Diactoros\ServerRequestFactory::fromGlobals(); | |
test('Diactoros getPath()', $r->getUri()->getPath()); | |
$r = Symfony\Component\HttpFoundation\Request::createFromGlobals(); | |
test('HttpFoundation getRequestUri()', $r->getRequestUri()); | |
test('HttpFoundation getScriptName()', $r->getScriptName()); | |
test('HttpFoundation getPathInfo()', $r->getPathInfo()); | |
test('HttpFoundation getBasePath()', $r->getBasePath()); | |
test('HttpFoundation getBaseUrl()', $r->getBaseUrl()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment