Depend on find-autoloader instead of "../../../" madness
This commit is contained in:
parent
0862121586
commit
ac3bc88772
3 changed files with 23 additions and 6 deletions
21
bin/find-autoloader.php
Normal file
21
bin/find-autoloader.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
function detectAndLoadVendor($path = __DIR__): void
|
||||
{
|
||||
$path = realpath($path);
|
||||
if ('/' == $path) {
|
||||
die("Could not find a suitable /vendor directory! Maybe you need to run composer install!\n");
|
||||
}
|
||||
|
||||
foreach (new DirectoryIterator($path) as $fileInfo) {
|
||||
if ($fileInfo->isDir() && 'vendor' == $fileInfo->getFilename()) {
|
||||
define('VENDOR_PATH', $fileInfo->getRealPath());
|
||||
require_once VENDOR_PATH.'/autoload.php';
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
detectAndLoadVendor($path.'/../');
|
||||
}
|
||||
|
||||
detectAndLoadVendor();
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once(__DIR__ . "/../../../../vendor/autoload.php");
|
||||
require_once(__DIR__ . "/find-autoloader.php");
|
||||
|
||||
use Benzine\App;
|
||||
use Benzine\Services\QueueService;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
$projRoot = __DIR__ . "/../../../..";
|
||||
if(file_exists("{$projRoot}/bootstrap.php")){
|
||||
require_once("{$projRoot}/bootstrap.php");
|
||||
}
|
||||
require_once("{$projRoot}/vendor/autoload.php");
|
||||
require_once(__DIR__ . "/find-autoloader.php");
|
||||
|
||||
use Benzine\Workers\AbstractQueueWorker;
|
||||
use duncan3dc\Forker\Fork;
|
||||
|
|
|
|||
Loading…
Reference in a new issue