Fix bug in which uuid CLI tool could not find autoloader

This commit is contained in:
Ben Ramsey
2014-01-27 18:16:40 -06:00
parent 806f46722f
commit f8d287eb67
+19 -7
View File
@@ -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;