Skip to content

Commit 5c2025b

Browse files
committed
added peridot-like autoloader find strategy, removed config loading
1 parent 165f2c1 commit 5c2025b

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

bin/padawan

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$autoloadPath = dirname(__DIR__) . "/autoload.php";
5-
if (!file_exists($autoloadPath)) {
6-
$autoloadPath =dirname(__DIR__) . "/vendor/autoload.php";
4+
$autoloaders = [
5+
__DIR__ . '/../../../autoload.php',
6+
__DIR__ . '/../vendor/autoload.php',
7+
__DIR__ . '/vendor/autoload.php',
8+
__DIR__ . '/../autoload.php'
9+
];
10+
11+
foreach ($autoloaders as $autoloader) {
12+
if (file_exists($autoloader)) {
13+
define("AUTOLOAD_PATH", $autoloader);
14+
break;
15+
}
716
}
8-
require($autoloadPath);
17+
18+
require(AUTOLOAD_PATH);
919

1020
set_time_limit(0);
1121
ini_set('memory_limit', '2048M');

bin/padawan-server

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@ use React\Http\Response;
55
use React\Http\Request;
66
use Application\HTTP\App;
77

8-
$autoloadPath = dirname(__DIR__) . "/autoload.php";
9-
$configPath = dirname(__DIR__) . "/mkusher/padawan/app/config/bin.php";
10-
if (!file_exists($autoloadPath)) {
11-
$autoloadPath = dirname(__DIR__) . "/vendor/autoload.php";
12-
$configPath = dirname(__DIR__) . "/app/config/bin.php";
8+
$autoloaders = [
9+
__DIR__ . '/../../../autoload.php',
10+
__DIR__ . '/../vendor/autoload.php',
11+
__DIR__ . '/vendor/autoload.php',
12+
__DIR__ . '/../autoload.php'
13+
];
14+
15+
foreach ($autoloaders as $autoloader) {
16+
if (file_exists($autoloader)) {
17+
define("AUTOLOAD_PATH", $autoloader);
18+
break;
19+
}
1320
}
1421

15-
require($configPath);
16-
require($autoloadPath);
22+
require(AUTOLOAD_PATH);
1723

1824
$noFsIO = false;
1925
$port = 15155;

0 commit comments

Comments
 (0)