#!/usr/bin/env php
<?php
ini_set('display_errors', 1);
if (PHP_SAPI !== 'cli') {
  fwrite(STDERR, "civix is a command-line tool. It requires PHP_SAPI=cli.\n");
  exit(1);
}
if (version_compare(phpversion(), '7.1.3', '<')) {
  fwrite(STDERR, "This version of civix requires PHP 7.1.3.\n");
  fwrite(STDERR, "For PHP 7.0 or older, see civix v20.06.0 or older.\n");
  exit(2);
}
$found = 0;
$autoloaders = array(
  dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php',
  dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'autoload.php',
);
foreach ($autoloaders as $autoloader) {
  if (file_exists($autoloader)) {
    require_once $autoloader;
    $found = 1;
    break;
  }
}
if (!$found) {
  fwrite(STDERR, "Failed to find autoloader\n");
  exit(3);
}
\CRM\CivixBundle\Application::main(__DIR__);
