From 6987992db39e99281a2152474b1df42f67369480 Mon Sep 17 00:00:00 2001 From: Alex Whitman Date: Sat, 12 Jan 2013 14:50:32 +0000 Subject: [PATCH] Add `--any-host` option to bind server to 0.0.0.0 Binds the server to `0.0.0.0` rather than `localhost` so that it can be accessed from other networked machines. --- src/Illuminate/Foundation/Console/ServeCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index 8acb48c64907..851c1b887bc9 100644 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -28,11 +28,17 @@ public function fire() { chdir($this->laravel['path.base']); + $host = 'localhost'; + if ($this->input->getOption('any-host') === true) + { + $host = '0.0.0.0'; + } + $port = $this->input->getOption('port'); - $this->info("Laravel development server started on port {$port}..."); + $this->info("Laravel development server started on {$host}:{$port}..."); - passthru("php -S localhost:{$port} -t public server.php"); + passthru("php -S {$host}:{$port} -t public server.php"); } /** @@ -43,6 +49,7 @@ public function fire() protected function getOptions() { return array( + array('any-host', null, InputOption::VALUE_NONE, 'Binds server to 0.0.0.0 for open access'), array('port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000), ); }