Skip to content

Commit

Permalink
Merge pull request #209 from brefphp/fix-require-error
Browse files Browse the repository at this point in the history
Improve error handling when Composer dependencies are missing
  • Loading branch information
mnapoli authored Oct 6, 2024
2 parents 0979238 + 1b94934 commit 1c0f1b0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions layers/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

$appRoot = getenv('LAMBDA_TASK_ROOT');

if (getenv('BREF_AUTOLOAD_PATH')) {
require getenv('BREF_AUTOLOAD_PATH');
} elseif (file_exists($appRoot . '/vendor/autoload.php')) {
require $appRoot . '/vendor/autoload.php';
$autoloadPath = $_SERVER['BREF_AUTOLOAD_PATH'] ?? null;
if (! $autoloadPath) {
$autoloadPath = $appRoot . '/vendor/autoload.php';
}
if (! file_exists($autoloadPath)) {
throw new RuntimeException('Could not find the Composer vendor directory. Did you run "composer require bref/bref"? Read https://bref.sh/docs/environment/php#custom-vendor-path if your Composer vendor directory is in a custom path.');
}

require $autoloadPath;

$runtimeClass = getenv('RUNTIME_CLASS');

Expand Down

0 comments on commit 1c0f1b0

Please sign in to comment.