Skip to content

Instantly share code, notes, and snippets.

@shinglyu
Created April 13, 2015 06:20
Show Gist options
  • Save shinglyu/ae8880369428f6b42845 to your computer and use it in GitHub Desktop.
Save shinglyu/ae8880369428f6b42845 to your computer and use it in GitHub Desktop.
dev server router for BzDeck
<?php
// This file is used for testing bzdeck with php's built-in web server.
// Usage:
// 1. php -S localhost:8000 dev-router.php
// 2. Visit http://localhost:8000
if (basename($_SERVER["PHP_SELF"]) == 'index.html' || basename($_SERVER["PHP_SELF"]) == ''){
// php's built-in server does not process html files
include('index.html');
} else {
return false; // serve the requested resource as-is.
}
?>
@kyoshino
Copy link

Here's my modified version:

<?php
// This file is used for testing BzDeck with PHP's built-in web server.
// Usage: 
// 1. php -S localhost:8000 dev-router.php
// 2. Visit http://localhost:8000

if (file_exists(__DIR__ . '/' . $_SERVER['REQUEST_URI'])) {
  // Serve the requested resource as-is.
  return false;
}

if ($_SERVER['REQUEST_URI'] === '/static/scripts/combined.js') {
  // Map combined.js to PHP
  include('components/combine-scripts.php');
} else {
  // Handle everything else
  include('index.php');
}

The dev server worked for me by adding this file as dev-router.php and renaming index.html to index.php 😺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment