Skip to content

Instantly share code, notes, and snippets.

@ryhmrt
Forked from tanakahisateru/builtin-server.php
Created November 19, 2012 09:57
Show Gist options
  • Save ryhmrt/4109907 to your computer and use it in GitHub Desktop.
Save ryhmrt/4109907 to your computer and use it in GitHub Desktop.
CakePHP2 by PHP5.4 builtin server
<?php
/**
* Place this file in CakePHP's root dir and do:
* $ php -S localhost:8080 builtin-server.php
* with PHP5.4
*/
if (strpos($_SERVER['REQUEST_URI'], '?')) {
list($path, $param) = preg_split('/\?/', $_SERVER['REQUEST_URI'], 2);
} else {
$path = $_SERVER['REQUEST_URI'];
}
if($path != '/' && (file_exists('app/webroot' . $path)))
{
header(sprintf('Location: http://%s/app/webroot%s',
$_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])); exit;
}
else if($path != '/' && (file_exists('./' . $path)))
{
return false;
}
else
{
//$_SERVER['PATH_INFO'] = $path;
require 'app/webroot/index.php';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment