-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
50 lines (40 loc) · 1.33 KB
/
bootstrap.php
File metadata and controls
50 lines (40 loc) · 1.33 KB
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
<?php
use App\Provider\AppProvider;
use App\Provider\ConsoleCommandProvider;
use App\Provider\DoctrineOrmProvider;
use App\Provider\RenderProvider;
use App\Provider\WebProvider;
use App\Support\Config;
use App\Support\ServiceProviderInterface;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Component\Dotenv\Dotenv;
use UltraLite\Container\Container;
require_once __DIR__ . '/vendor/autoload.php';
AnnotationRegistry::registerLoader('class_exists');
(new Dotenv())->loadEnv(__DIR__ . '/.env');
$env = getenv('APP_ENV');
if (!$env) {
$env = 'dev';
}
$config = new Config(__DIR__ . '/config', $env, __DIR__);
$providers = [
AppProvider::class,
DoctrineOrmProvider::class,
ConsoleCommandProvider::class,
WebProvider::class,
RenderProvider::class,
];
$container = new Container([
Config::class => static function () use ($config) { return $config; },
]);
foreach ($providers as $providerClassName) {
if (!class_exists($providerClassName)) {
throw new RuntimeException(sprintf('Provider %s not found', $providerClassName));
}
$provider = new $providerClassName;
if (!($provider instanceof ServiceProviderInterface)) {
throw new RuntimeException(sprintf('%s class is not a Service Provider', $providerClassName));
}
$provider->register($container);
}
return $container;