ORM/bin/find-autoloader.php

29 lines
717 B
PHP
Raw Normal View History

<?php
2019-09-04 13:53:44 +00:00
2024-04-14 16:13:59 +00:00
declare(strict_types=1);
function detectAndLoadVendor($path = __DIR__): void
2019-09-04 13:53:44 +00:00
{
$path = realpath($path);
2019-09-04 13:53:44 +00:00
if ('/' == $path) {
2021-01-22 04:20:21 +00:00
exit("Could not find a suitable /vendor directory! Maybe you need to run composer install!\n");
}
2019-09-04 13:53:44 +00:00
foreach (new DirectoryIterator($path) as $fileInfo) {
if ($fileInfo->isDir() && 'vendor' == $fileInfo->getFilename()) {
define('VENDOR_PATH', $fileInfo->getRealPath());
2021-01-22 04:20:21 +00:00
2024-04-14 16:13:59 +00:00
require_once VENDOR_PATH . '/autoload.php';
if(!defined('APP_ROOT')) {
define('APP_ROOT', VENDOR_PATH . "/../");
}
2019-09-04 13:53:44 +00:00
return;
}
}
2024-04-14 16:13:59 +00:00
detectAndLoadVendor($path . '/../');
}
2020-06-15 06:19:42 +00:00
2019-09-04 13:53:44 +00:00
detectAndLoadVendor();