File size: 1,779 Bytes
cf14c12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

declare(strict_types=1);

use Dotenv\Dotenv;
use Easy\Container\Container;
use Shared\Infrastructure\Config\Config;
use Shared\Infrastructure\Config\ConfigResolver;

$rootDir = dirname(__DIR__);

// Load environment variables.
$dotenv = Dotenv::createImmutable(
    $rootDir,
    ['.env', '.env.example']
)->safeLoad();

// Load configuration.
$config = new Config();

$webroot = $rootDir . '/public';
$config->set('dirs', [
    'root' => $rootDir,
    'webroot' => $webroot,
    'cache' => $rootDir . '/var/cache',
    'log' => $rootDir . '/var/log/',
    'src' => $rootDir . '/src',
    'views' => $rootDir . '/resources/views',
    'uploads' => $webroot . '/uploads',
    'locale' => $rootDir . '/locale',
    'plugins' => $webroot . '/content/plugins',
]);
$config->set("enable_debugging", env('DEBUG', false));
$config->set('enable_caching', env('CACHE', false));

$lc = json_decode(file_get_contents($rootDir . '/locale/locale.json'), true);
$config->set('locale', $lc);

// Setup container.
$container = new Container();

$container->pushResolver(new ConfigResolver($config));
$container->set(Config::class, $config);

$container->set('bootstrappers', require 'config/bootstrappers.php');
$container->set('commands', require 'config/commands.php');
$container->set('migrations', require 'config/migrations.php');
$container->set('providers', require 'config/providers.php');

// Get version
$version = file_exists($rootDir . '/VERSION')
    ? file_get_contents($rootDir . '/VERSION')
    : 'dev';
$container->set('version', $version ? trim($version) : 'dev');

// Get license
$license = file_exists($rootDir . '/LICENSE')
    ? file_get_contents($rootDir . '/LICENSE')
    : null;

$container->set('license', $license ? trim($license) : null);


return $container;