Skip to content

Commit 1c0f1b0

Browse files
authored
Merge pull request #209 from brefphp/fix-require-error
Improve error handling when Composer dependencies are missing
2 parents 0979238 + 1b94934 commit 1c0f1b0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

layers/bootstrap.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
$appRoot = getenv('LAMBDA_TASK_ROOT');
44

5-
if (getenv('BREF_AUTOLOAD_PATH')) {
6-
require getenv('BREF_AUTOLOAD_PATH');
7-
} elseif (file_exists($appRoot . '/vendor/autoload.php')) {
8-
require $appRoot . '/vendor/autoload.php';
5+
$autoloadPath = $_SERVER['BREF_AUTOLOAD_PATH'] ?? null;
6+
if (! $autoloadPath) {
7+
$autoloadPath = $appRoot . '/vendor/autoload.php';
98
}
9+
if (! file_exists($autoloadPath)) {
10+
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.');
11+
}
12+
13+
require $autoloadPath;
1014

1115
$runtimeClass = getenv('RUNTIME_CLASS');
1216

0 commit comments

Comments
 (0)