Replaced cli execution using expressive middleware by symfony/console

This commit is contained in:
Alejandro Celaya
2016-07-03 09:14:27 +02:00
parent 1c6250618a
commit 35147fecb2
4 changed files with 108 additions and 11 deletions

17
bin/cli
View File

@@ -1,17 +1,14 @@
#!/usr/bin/env php
<?php
use Acelaya\UrlShortener\CliCommands\GenerateShortcodeCommand;
use Interop\Container\ContainerInterface;
use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\Uri;
use Zend\Expressive\Application;
use Symfony\Component\Console\Application as CliApp;
/** @var ContainerInterface $container */
$container = include __DIR__ . '/../config/container.php';
/** @var Application $app */
$app = $container->get(Application::class);
$command = count($_SERVER['argv']) > 1 ? $_SERVER['argv'][1] : '';
$request = ServerRequestFactory::fromGlobals()
->withMethod('CLI')
->withUri(new Uri(sprintf('/%s', $command)));
$app->run($request);
$app = new CliApp();
$app->addCommands([
$container->get(GenerateShortcodeCommand::class),
]);
$app->run();