Created
August 18, 2012 09:28
-
-
Save shevron/3385625 to your computer and use it in GitHub Desktop.
A wrapper script for serving ZF apps with PHP's built in Web server
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 | |
/** | |
* PHP Built-in Web Server wrapper for ZF apps | |
*/ | |
$reqUri = $_SERVER['REQUEST_URI']; | |
if (strpos($reqUri, '?') !== false) { | |
$reqUri = substr($reqUri, 0, strpos($reqUri, '?')); | |
} | |
$target = realpath(__DIR__ . $reqUri); | |
if ($target && is_file($target)) { | |
// Security check: make sure the file is under the public dir | |
if (strpos($target, __DIR__) === 0) { | |
// Tell PHP to directly serve the requested file | |
return false; | |
} | |
} | |
// Load the ZF app front controller script | |
require __DIR__ . '/index.php'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment