Browse Source

Fix cake console so it works from vendor/bin

mark_story 13 years ago
parent
commit
05c65a1b1b
1 changed files with 19 additions and 4 deletions
  1. 19 4
      lib/Cake/Console/cake.php

+ 19 - 4
lib/Cake/Console/cake.php

@@ -26,9 +26,24 @@ if ($appIndex !== false) {
 	$dir = $argv[$appIndex + 1];
 	require $dir . '/Config/bootstrap.php';
 }
-// Default app directory layout
-if (!$loaded && file_exists($root . '/App/Config/bootstrap.php')) {
-	require $root . '/App/Config/bootstrap.php';
+
+$locations = [
+	// Default repository layout.
+	$root . '/App/Config/bootstrap.php',
+	// Composer vendor directory
+	$root . '/../../Config/bootstrap.php',
+];
+
+foreach ($locations as $path) {
+	if (file_exists($path)) {
+		$loaded = true;
+		require $path;
+		break;
+	}
+}
+if (!$loaded) {
+	fwrite(STDERR, "Unable to load CakePHP libraries, check your configuration/installation.\n");
+	exit(10);
 }
-unset($root, $loaded, $appIndex, $dir);
+unset($root, $loaded, $appIndex, $dir, $path, $locations);
 exit(Cake\Console\ShellDispatcher::run($argv));