Skip to content

Instantly share code, notes, and snippets.

@shevron
Created August 18, 2012 09:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shevron/3385625 to your computer and use it in GitHub Desktop.
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
<?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