#!/usr/bin/env php
<?php
/**
 * Pimcore
 *
 * This source file is available under two different licenses:
 * - GNU General Public License version 3 (GPLv3)
 * - Pimcore Enterprise License (PEL)
 * Full copyright and license information is available in
 * LICENSE.md which is distributed with this source code.
 *
 * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
 * @license    http://www.pimcore.org/license     GPLv3 and PEL
 */

use Pimcore\Config;
use Pimcore\Install\InstallerKernel;
use Pimcore\Version;
use Symfony\Bundle\FrameworkBundle\Console\Application;

error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
@ini_set('display_errors', 'On');

$maxExecutionTime = 0;
@ini_set('max_execution_time', $maxExecutionTime);
set_time_limit($maxExecutionTime);

if (!defined('PIMCORE_PROJECT_ROOT')) {
    define(
        'PIMCORE_PROJECT_ROOT',
        getenv('PIMCORE_PROJECT_ROOT')
            ?: getenv('REDIRECT_PIMCORE_PROJECT_ROOT')
            ?: realpath(__DIR__ . '/..')
    );
}

/** @var $loader \Composer\Autoload\ClassLoader */
$loader = include PIMCORE_PROJECT_ROOT . '/vendor/autoload.php';
Pimcore::setAutoloader($loader);

require_once PIMCORE_PROJECT_ROOT . '/pimcore/config/constants.php';
require_once PIMCORE_PROJECT_ROOT . '/pimcore/lib/helper-functions.php';

if (!class_exists('Zend_Date')) {
    // if ZF is not loaded, we need to provide some compatibility stubs
    // for a detailed description see the included file
    require_once PIMCORE_PATH . '/stubs/compatibility-v4.php';
}

$kernel = new InstallerKernel(PIMCORE_PROJECT_ROOT, Config::getEnvironment(), true);

$application = new Application($kernel);
$application->setName('Pimcore Installer');
$application->setVersion(Version::getVersion());
$application->setDefaultCommand('pimcore:install', true);
$application->run();
