-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap-api.php
51 lines (38 loc) · 1.28 KB
/
bootstrap-api.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
<?php
use Slim\App;
use Symfony\Component\Console\Application;
use Symfony\Component\Finder\Finder;
use Dotenv\Dotenv;
use HotRodCli\CommandsBootstrap;
use Symfony\Component\Filesystem\Filesystem;
use HotRodCli\AppContainer;
use Symfony\Component\Console\Output\BufferedOutput;
use \Symfony\Component\Console\Input\ArrayInput;
$api = new App();
$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('Magento Submarine', '0.0.3'));
$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());
$app->bind('commands', $commands);
$app->bind(BufferedOutput::class, new BufferedOutput());
$commandBootstrap = new CommandsBootstrap($commands, $app);
$commandBootstrap->register($app->resolve(Application::class));
require "routes.php";
$api->run();