-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
28 lines (22 loc) · 761 Bytes
/
init.php
File metadata and controls
28 lines (22 loc) · 761 Bytes
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
<?php
namespace podmail;
// Where are we?
$baseDir = dirname(__FILE__);
// Make sure all execution starts from this base path
chdir($baseDir);
// Load dependencies
require_once 'vendor/autoload.php';
// Read configuration file
$configFile = $baseDir . '/config.json';
if (!file_exists($configFile)) throw new \Exception("Missing config file.");
$raw = file_get_contents($configFile);
$configValues = json_decode($raw, true);
$config = ['baseDir' => dirname(__FILE__)];
foreach ($configValues as $key=>$value) $config[$key] = $value;
// Preapre the database
$config['db'] = new Db($config);
// Preprae Redis
$redis = new \Redis();
$redis->pconnect($config['redis']['server'], $config['redis']['port']);
$redis->clearLastError();
$config['redis'] = $redis;