Add composer autoload guard

This commit is contained in:
Jansen Price 2020-08-27 11:49:51 -05:00
parent a305a5a92a
commit a42e46aaad
1 changed files with 24 additions and 1 deletions

View File

@ -1,7 +1,30 @@
#!/usr/bin/env php
<?php
require_once dirname(__DIR__) . "/vendor/autoload.php";
// Find where the composer autoload is
// This tool was installed as a composed dependency or directly
$root = realpath(dirname(__DIR__));
$autoload_locations = array(
__DIR__ . '/../../../autoload.php',
$root . DIRECTORY_SEPARATOR . 'vendor/autoload.php'
);
foreach ($autoload_locations as $file) {
if (file_exists($file)) {
define('ORBIT_COMPOSER_AUTOLOAD', $file);
break;
}
}
// Composer autoload require guard
if (!defined('ORBIT_COMPOSER_AUTOLOAD')) {
die(
"You must run the command `composer install` from the terminal "
. "in the directory '$root' before using this tool.\n"
);
}
// Load composer autoloader
$autoload = require_once ORBIT_COMPOSER_AUTOLOAD;
// Define command line args for this client
// And fetch args passed in by invocation