-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.php
42 lines (31 loc) · 1.06 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
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Finder\Finder;
use Dotenv\Dotenv;
use HotRodCli\CommandsBootstrap;
use Symfony\Component\Filesystem\Filesystem;
use HotRodCli\AppContainer;
$commands = require 'commands.php';
$finder = new Finder();
$finder->files()
->ignoreDotFiles(false)
->in(__DIR__)
->name('.env');
$mode = 'production';
if ($finder->count() === 1) {
$env = new Dotenv(__DIR__);
$env->load();
$mode = getenv('env');
}
$cdAppDir = $mode === 'development' ? '' : '/../../..';
$app = new AppContainer();
$app->bind(AppContainer::class, $app);
$app->bind(Application::class, new Application('Hotrod cli', '0.0.4'));
$app->bind('app_dir', __DIR__ . $cdAppDir);
$app->bind('submarine_dir', __DIR__);
$app->bind('resource_dir', __DIR__ . '/resources');
$app->bind(Filesystem::class, new Filesystem());
$app->bind(Finder::class, new Finder());
$commandBootstrap = new CommandsBootstrap($commands, $app);
$commandBootstrap->register($app->resolve(Application::class));
($app->resolve(Application::class))->run();