Skip to content

Instantly share code, notes, and snippets.

@tanakahisateru
Created October 5, 2011 19:01
Show Gist options
  • Save tanakahisateru/1265330 to your computer and use it in GitHub Desktop.
Save tanakahisateru/1265330 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
*/
list($path, $param) = preg_split('/\?/', $_SERVER['REQUEST_URI'], 2);
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