#!/usr/bin/env php
<?php

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;

if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
    echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
}

set_time_limit(0);

require dirname(__DIR__).'/vendor/autoload.php';

$debug = (bool) ($_SERVER['APP_DEBUG'] ?? true);
$appEnv = $_SERVER['APP_ENV'] ?? 'dev';
if ($debug) {
    umask(0000);
    Debug::enable();
}

$input = new ArgvInput();
$kernel = new Ecotone\SymfonyBundle\App\Kernel($appEnv, $debug);
$application = new Application($kernel);
$application->run($input);