diff --git a/bin/uuid b/bin/uuid index 982781e..1ce97bc 100755 --- a/bin/uuid +++ b/bin/uuid @@ -13,17 +13,29 @@ date_default_timezone_set('UTC'); if (PHP_SAPI !== 'cli') { - echo 'Warning: uuid should be invoked via the CLI version of PHP, not the ' . PHP_SAPI . ' SAPI' . PHP_EOL; + die('uuid should be invoked via the CLI version of PHP, not the ' . PHP_SAPI . ' SAPI' . PHP_EOL); } -if (!file_exists(__DIR__ . '/../vendor/autoload.php')) { - echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL . - 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL . - 'php composer.phar install' . PHP_EOL; - exit(1); +$files = array( + __DIR__ . '/../vendor/autoload.php', + __DIR__ . '/../../../autoload.php', +); + +foreach ($files as $file) { + if (file_exists($file)) { + require $file; + define('UUID_COMPOSER_INSTALL', $file); + break; + } } -require __DIR__ . '/../vendor/autoload.php'; +if (!defined('UUID_COMPOSER_INSTALL')) { + die( + 'You need to set up the project dependencies using the following commands:' . PHP_EOL . + 'curl -s http://getcomposer.org/installer | php' . PHP_EOL . + 'php composer.phar install' . PHP_EOL + ); +} use Rhumsaa\Uuid\Console\Application; use Rhumsaa\Uuid\Console\Command;