From c83d05fe09845ff554bca23d84be73ac47c4fde0 Mon Sep 17 00:00:00 2001 From: Vivek Dhumal Date: Sat, 17 Jun 2017 19:13:22 +0530 Subject: [PATCH] Create ServeCommand.php php katana serve command will serve local site with php built-in server with option to configurable port as -p "port" | --port "port" --- src/Commands/ServeCommand.php | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/Commands/ServeCommand.php diff --git a/src/Commands/ServeCommand.php b/src/Commands/ServeCommand.php new file mode 100644 index 0000000..55c5a92 --- /dev/null +++ b/src/Commands/ServeCommand.php @@ -0,0 +1,45 @@ +setName('serve') + ->setDescription('Serve local site with php built-in server.') + ->addOption( + 'port', + 'p', + InputOption::VALUE_REQUIRED, + 'What port should we use?', + 8000 + ); + } + + /** + * Execute the command. + * + * @param InputInterface $input + * @param OutputInterface $output + * + * @return void + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $port = $input->getOption('port'); + + $output->writeln("Started listening on http://localhost:{$port}"); + passthru("php -S localhost:{$port} -t public"); + } +}