Skip to content

Commit

Permalink
Find loader path relative to COMPOSER_VENDOR_DIR environment variab…
Browse files Browse the repository at this point in the history
…le instead.

Signed-off-by: Yusup Hambali <supalpuket@gmail.com>
  • Loading branch information
yus-ham committed May 21, 2020
1 parent 62294af commit 0db452a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public static function load()
*/
private static function getClassLoader()
{
$autoload = ($_ENV['COMPOSER_VENDOR_DIR'] ?? getenv('COMPOSER_VENDOR_DIR')) . '/autoload.php';

if (file_exists($autoload)) {
return include $autoload;
}

if (file_exists(__DIR__ . '/../../../autoload.php')) {
return include __DIR__ . '/../../../autoload.php';
}
Expand All @@ -74,10 +80,6 @@ private static function getClassLoader()
return include __DIR__ . '/../vendor/autoload.php';
}

if (file_exists('vendor/autoload.php')) {
return include 'vendor/autoload.php';
}

throw new RuntimeException('Cannot detect composer autoload. Please run composer install');
}

Expand Down

0 comments on commit 0db452a

Please sign in to comment.