Last Updated: February 25, 2016
·
2.103K
· nxqd

Hassle free wordpress development with php built in server

To remove all the hassle of installing nginx, configure php-fpm. You can use the built in php server which is really convenient for development.

Paste the content on this gist https://gist.github.com/rhacker/8134339 to router.php file in wordpress folder then you can start developing with this command :

   <?php

$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root); 
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
set_include_path(get_include_path().':'.__DIR__);
if(file_exists($root.$path)) 
{
    if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') 
    $path = rtrim($path,'/').'/index.php';
    if(strpos($path,'.php') === false) return false;
    else {
       chdir(dirname($root.$path));
       require_once $root.$path;
    }
 }else include_once 'index.php';

  // php -S localhost:8080 router.php