* For the full copyright and license information, please view the LICENSE
11
* file that was distributed with this source code.
12
*/
13
14
use Composer\Autoload\ClassLoader;
15
16
function includeIfExists(string $file): ?ClassLoader
17
{
18
return file_exists($file) ? include $file : null;
19
}
20
21
// includes then returns autoloader
22
switch (true) {
23
case ($loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')): // standalone
24
break;
25
case ($loader = includeIfExists(__DIR__ . '/../../../autoload.php')): // as a Composer dependency
26
break;
27
case ($loader = includeIfExists('vendor/autoload.php')): // as a Composer dependency, relative to CWD
28
break;
29
default:
30
printf('You must set up the project dependencies using `composer install`%sSee https://getcomposer.org/download/ for instructions on installing Composer%s', PHP_EOL, PHP_EOL);