mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 23:23:42 -06:00
Created installation script and installation command
This commit is contained in:
parent
2b2c0b7c13
commit
cffa43a155
11
bin/install
Executable file
11
bin/install
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
use Shlinkio\Shlink\CLI\Command\Install\InstallCommand;
|
||||||
|
use Symfony\Component\Console\Application;
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
$app = new Application();
|
||||||
|
$app->add(new InstallCommand());
|
||||||
|
$app->setDefaultCommand('shlink:install');
|
||||||
|
$app->run();
|
2
config/params/.gitignore
vendored
Normal file
2
config/params/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
59
module/CLI/src/Command/Install/InstallCommand.php
Normal file
59
module/CLI/src/Command/Install/InstallCommand.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
namespace Shlinkio\Shlink\CLI\Command\Install;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Question\Question;
|
||||||
|
|
||||||
|
class InstallCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var InputInterface
|
||||||
|
*/
|
||||||
|
private $input;
|
||||||
|
/**
|
||||||
|
* @var OutputInterface
|
||||||
|
*/
|
||||||
|
private $output;
|
||||||
|
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
$this->setName('shlink:install')
|
||||||
|
->setDescription('Installs Shlink');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$this->input = $input;
|
||||||
|
$this->output = $output;
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$output->writeln([
|
||||||
|
'<info>Welcome to Shlink!!</info>',
|
||||||
|
'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(
|
||||||
|
' <question>' . $text . ':</question> ',
|
||||||
|
$default
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user