Skip to content

Instantly share code, notes, and snippets.

@iturgeon
Last active December 15, 2015 09:28
Show Gist options
  • Save iturgeon/5238182 to your computer and use it in GitHub Desktop.
Save iturgeon/5238182 to your computer and use it in GitHub Desktop.
Adding php 5.4's development server to FuelPHP's oil commands (built for fuelphp 1.6)
<?php
if (file_exists($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI']))
{
// bypass existing file processing
return false;
}
else
{
// route requests though the normal path
include($_SERVER['DOCUMENT_ROOT'].'/index.php');
}
<?php
/* === rom fuelphp 1.6 oil/command.php @line 45 ====
This will allow you to override the arguments with named cli params
requires bootstrap_dev.php to handle the apache mod rewrite routing
allows commands like:
oil server
oil server port=8080 host=0.0.0.0
*/
switch ($args[1])
{
case 's':
case 'server':
$php = \Cli::option('php', 'php');
$port = \Cli::option('p', \Cli::option('port', '8000'));
$host = \Cli::option('h', \Cli::option('host', 'localhost'));
$docroot = \Cli::option('d', \Cli::option('docroot', 'public/'));
$router = \Cli::option('r', \Cli::option('router', COREPATH.'bootstrap_dev.php'));
\Cli::write("Listening on http://$host:$port");
\Cli::write("Document root is $docroot");
\Cli::write("Press Ctrl-C to quit.");
passthru("$php -S $host:$port -t $docroot $router");
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment