-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathbootstrap.php
More file actions
27 lines (20 loc) · 1.18 KB
/
bootstrap.php
File metadata and controls
27 lines (20 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env php
<?php declare(strict_types=1);
$appRoot = getenv('LAMBDA_TASK_ROOT');
$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;
// `RUNTIME_CLASS` is for backwards compatibility with Bref v2's environment variable
$runtimeClass = $_SERVER['BREF_RUNTIME'] ?? $_SERVER['RUNTIME_CLASS'];
if (empty($runtimeClass)) {
throw new RuntimeException('The environment variable `BREF_RUNTIME` is not set, are you trying to use Bref v2 with Bref v3 layers? Make sure to follow the Bref documentation to use the right layers for your current Bref version.');
}
if (! class_exists($runtimeClass)) {
throw new RuntimeException("Bref is not installed in your application (could not find the class \"$runtimeClass\" in Composer dependencies). Did you run \"composer require bref/bref\"?");
}
$runtimeClass::run();