From cffa43a155adbe7b50eed799a78df3b5aecfefe5 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 14 Aug 2016 09:09:23 +0200 Subject: [PATCH] Created installation script and installation command --- bin/install | 11 ++++ config/params/.gitignore | 2 + .../src/Command/Install/InstallCommand.php | 59 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100755 bin/install create mode 100644 config/params/.gitignore create mode 100644 module/CLI/src/Command/Install/InstallCommand.php diff --git a/bin/install b/bin/install new file mode 100755 index 00000000..651ae8e3 --- /dev/null +++ b/bin/install @@ -0,0 +1,11 @@ +#!/usr/bin/env php +add(new InstallCommand()); +$app->setDefaultCommand('shlink:install'); +$app->run(); diff --git a/config/params/.gitignore b/config/params/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/config/params/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/module/CLI/src/Command/Install/InstallCommand.php b/module/CLI/src/Command/Install/InstallCommand.php new file mode 100644 index 00000000..2e3b0af3 --- /dev/null +++ b/module/CLI/src/Command/Install/InstallCommand.php @@ -0,0 +1,59 @@ +setName('shlink:install') + ->setDescription('Installs Shlink'); + } + + public function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + $params = []; + + $output->writeln([ + 'Welcome to Shlink!!', + 'This will guide you through the installation process.', + ]); + + $params['DB_NAME'] = $this->ask('Database name', 'shlink'); + } + + /** + * @param string $text + * @param string|null $default + * @return string + */ + protected function ask($text, $default = null) + { + /** @var QuestionHelper $questionHelper */ + $questionHelper = $this->getHelper('question'); + + if (isset($default)) { + $text .= ' (defaults to ' . $default . ')'; + } + return $questionHelper->ask($this->input, $this->output, new Question( + ' ' . $text . ': ', + $default + )); + } +}