-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbootstrap.php
52 lines (45 loc) · 1.48 KB
/
bootstrap.php
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php declare(strict_types=1);
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://swoft.org/docs
* @contact [email protected]
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/
use SwoftTest\Testing\TestApplication;
// vendor at package dir
$packagePath = dirname(__DIR__);
if (file_exists($packagePath . '/vendor/autoload.php')) {
/** @noinspection PhpIncludeInspection */
require $packagePath . '/vendor/autoload.php';
} else {
$componentDir = dirname(__DIR__, 3);
$loaderFiles = [
// vendor at swoft/component dir
$componentDir . '/vendor/autoload.php',
// application's vendor
dirname(__DIR__, 5) . '/autoload.php',
];
/** @var Composer\Autoload\ClassLoader $loader */
$found = false;
foreach ($loaderFiles as $loaderFile) {
if (file_exists($loaderFile)) {
/** @noinspection PhpIncludeInspection */
$loader = require $loaderFile;
$found = true;
break;
}
}
if (!$found) {
exit('Please run "composer install" to install the dependencies' . PHP_EOL);
}
// need load testing psr4 config map
$jsonFile = $componentDir . '/composer.json';
$jsonData = json_decode(file_get_contents($jsonFile), true);
foreach ($jsonData['autoload-dev']['psr-4'] as $prefix => $dir) {
$loader->addPsr4($prefix, $componentDir . '/' . $dir);
}
}
$app = new TestApplication(__DIR__);
$app->run();