#!/usr/bin/env php
<?php
/**
 * @file
 * This is the front/entry script for the CLI.
 */

// Send errors to stderr, not stdout.
ini_set('display_errors', 'stderr');

// Avoid displaying PHP errors twice.
ini_set('log_errors', '0');

// Disable early deprecation notices, e.g. those relating to Symfony Console.
// Deprecation-level notices may be switched back on inside the application, or with the CLI_DEBUG environment variable.
error_reporting(getenv('CLI_DEBUG') ? E_ALL : E_ALL & ~E_DEPRECATED);

if (version_compare(PHP_VERSION, '5.5.9', '<')) {
    printf("This tool requires at least PHP 5.5.9. You currently have %s installed. Please upgrade your PHP version.\n", PHP_VERSION);
    exit(1);
}

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
    require __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
    // we are globally installed via Composer
    require __DIR__ . '/../../../autoload.php';
} else {
    echo "Composer autoload file not found.\n";
    echo "You need to run 'composer install'.\n";
    exit(1);
}

(new \Platformsh\Cli\Application())->run();
