|
@@ -2,13 +2,48 @@
|
|
|
<?php
|
|
|
namespace Fgm\ComposerCheck;
|
|
|
|
|
|
-require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
+
|
|
|
+ * Guess the path where the Composer autoloader is available.
|
|
|
+ *
|
|
|
+ * TODO find a better logic.
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ * The path to the
|
|
|
+ */
|
|
|
+function setupAutoload($debug = FALSE) {
|
|
|
+ $runningFrom = [
|
|
|
+
|
|
|
+ "git clone" => __DIR__ . '/../vendor',
|
|
|
+
|
|
|
+ "composer default" => __DIR__ . '/../../../../vendor',
|
|
|
+ ];
|
|
|
+
|
|
|
+ foreach ($runningFrom as $kind => $location) {
|
|
|
+ $path = "${location}/autoload.php";
|
|
|
+ if (is_file($path) && is_readable($path)) {
|
|
|
+ $autoloader = include_once $path;
|
|
|
+ if ($autoloader instanceof \Composer\Autoload\ClassLoader) {
|
|
|
+ if ($debug) {
|
|
|
+ echo "Install appears to be: $kind\n";
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return realpath(dirname($location));
|
|
|
+}
|
|
|
|
|
|
|
|
|
$all = FALSE;
|
|
|
+$debug = TRUE;
|
|
|
$useYaml = TRUE;
|
|
|
|
|
|
-$factory = new LoaderFactory(__DIR__ . '/..', $all);
|
|
|
+$path = setupAutoload($debug);
|
|
|
+if (empty($path)) {
|
|
|
+ die("Autoloader not found.");
|
|
|
+}
|
|
|
+$factory = new LoaderFactory($path, $all);
|
|
|
|
|
|
$requirementsLoader = $factory->createLoader('requirements');
|
|
|
$requirementsLoader->load();
|