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"); + } +}