#!/usr/bin/env php
<?php
/**
 * Runs Couscous.
 *
 * @author Matthieu Napoli <matthieu@mnapoli.fr>
 */

use Couscous\Application\ContainerFactory;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Output\ConsoleOutput;

if (version_compare(phpversion(), '5.4', '<')) {
    die('You must use PHP >= 5.4 in order to use Couscous. Please upgrade your PHP version.');
}

if (!ini_get('date.timezone')) {
    date_default_timezone_set('UTC');
}

// Phar
if (isset($include)) {
    require_once $include . '/vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../vendor/autoload.php')) {
    require_once __DIR__ . '/../vendor/autoload.php';
} else {
    require_once __DIR__ . '/../../../autoload.php';
}

$output = new ConsoleOutput();

$factory = new ContainerFactory();
$container = $factory->createContainer();

// Set the logger
$logger = $container->make('Symfony\Component\Console\Logger\ConsoleLogger', [
    'output' => $output,
]);
$container->set('Psr\Log\LoggerInterface', $logger);

/** @var Application $application */
$application = $container->get('application');
$application->run();
