From e5c69f2c601aba88a6f10267360e272ebd77378e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E7=BA=A7CV=E5=B7=A5=E7=A8=8B=E5=B8=88?= <2535688890@qq.com> Date: Sun, 12 Mar 2023 15:40:38 +0000 Subject: [PATCH 1/2] php think run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 高级CV工程师 <2535688890@qq.com> --- application/admin/command/RunServer.php | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 application/admin/command/RunServer.php diff --git a/application/admin/command/RunServer.php b/application/admin/command/RunServer.php new file mode 100644 index 000000000..acf90fd7d --- /dev/null +++ b/application/admin/command/RunServer.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- +namespace app\admin\command; + +use think\console\Command; +use think\console\Input; +use think\console\input\Option; +use think\console\Output; + +class RunServer extends Command +{ + public function configure() + { + $this->setName('run') + ->addOption('host', 'H', Option::VALUE_OPTIONAL, + 'The host to server the application on', '127.0.0.1') + ->addOption('port', 'p', Option::VALUE_OPTIONAL, + 'The port to server the application on', 8000) + ->addOption('root', 'r', Option::VALUE_OPTIONAL, + 'The document root of the application', ROOT_PATH . 'public') + ->setDescription('PHP Built-in Server for ThinkPHP'); + } + + public function execute(Input $input, Output $output) + { + $host = $input->getOption('host'); + $port = $input->getOption('port'); + $root = $input->getOption('root'); + + $command = sprintf( + 'php -S %s:%d -t %s %s', + $host, + $port, + escapeshellarg($root), + escapeshellarg($root . DIRECTORY_SEPARATOR . 'router.php') + ); + + $output->writeln(sprintf('ThinkPHP Development server is started On ', $host, $port)); + $output->writeln(sprintf('You can exit with `CTRL-C`')); + $output->writeln(sprintf('Document root is: %s', $root)); + passthru($command); + } + +} -- Gitee From cd12480e2024d660a2b0f6b0063071988958a9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E7=BA=A7CV=E5=B7=A5=E7=A8=8B=E5=B8=88?= <2535688890@qq.com> Date: Sun, 12 Mar 2023 15:42:00 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=8A=9F=E8=83=BD=20php=20think=20r?= =?UTF-8?q?un?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 高级CV工程师 <2535688890@qq.com> --- application/command.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/command.php b/application/command.php index ab4178a36..b6e76a9b6 100755 --- a/application/command.php +++ b/application/command.php @@ -17,4 +17,5 @@ return [ 'app\admin\command\Min', 'app\admin\command\Addon', 'app\admin\command\Api', + 'app\admin\command\RunServer', ]; -- Gitee