forked from XChess/XChess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
53 lines (42 loc) · 1.37 KB
/
bootstrap.php
File metadata and controls
53 lines (42 loc) · 1.37 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
51
52
53
<?php
declare(strict_types=1);
/**
* XChess.
*
* The worlds best chess playing website.
*
* @author XChess Contributors <https://github.com/orgs/XChess/people>
*
* @link <https://github.com/XChess> XChess Code.
*/
use Symfony\Component\Debug\Debug;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\Yaml\Yaml;
require_once __DIR__ . '/vendor/autoload.php';
// Load the dotenv configuration file.
(new Dotenv())->load(__DIR__ . '/xchess.env');
// Determine if we should run in debug mode.
if ($_ENV['APP_DEBUG'])
{
Debug::enable();
}
// The directory where the configuration files are.
$dir = __DIR__ . '/config/';
// Load the configuration files.
$config['hasher'] = Yaml::parseFile($dir . 'hasher.yml');
// Create a new container.
$containerBuilder = new ContainerBuilder();
// Set parameters.
$containerBuilder->setParameter('hasher.options', $config['hasher']['hasher']);
// Initiate a hash manager.
$containerBuilder->register('hasher', 'XChess\Engine\Hasher')->addArgument('%hasher.options%');
// Initiate a encrypter.
$containerBuilder->register('encrypter', 'XChess\Engine\Encryption');
// Make the container accessable through a function.
function app(string $service)
{
global $containerBuilder;
return $containerBuilder->get($service);
}