Moved command and app creation logic to a factory for install scripts

This commit is contained in:
Alejandro Celaya
2017-07-05 18:12:03 +02:00
parent dcc09975a9
commit 2368b634e3
4 changed files with 57 additions and 16 deletions
+6 -8
View File
@@ -1,16 +1,14 @@
#!/usr/bin/env php
<?php
use Shlinkio\Shlink\CLI\Command\Install\InstallCommand;
use Shlinkio\Shlink\CLI\Factory\InstallApplicationFactory;
use Symfony\Component\Console\Application;
use Symfony\Component\Filesystem\Filesystem;
use Zend\Config\Writer\PhpArray;
use Zend\ServiceManager\ServiceManager;
chdir(dirname(__DIR__));
require __DIR__ . '/../vendor/autoload.php';
$app = new Application();
$command = new InstallCommand(new PhpArray(), new Filesystem());
$app->add($command);
$app->setDefaultCommand($command->getName());
$app->run();
$container = new ServiceManager(['factories' => [
Application::class => InstallApplicationFactory::class,
]]);
$container->build(Application::class)->run();