-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathboot.php
51 lines (43 loc) · 1.04 KB
/
boot.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
/**
* OpenTHC CRE Bootstrap
*
* SPDX-License-Identifier: MIT
*/
define('APP_ROOT', __DIR__);
error_reporting(E_ALL & ~ E_NOTICE & ~ E_WARNING);
openlog('openthc-cre', LOG_ODELAY|LOG_PID, LOG_LOCAL0);
require_once(APP_ROOT . '/vendor/autoload.php');
if ( ! \OpenTHC\Config::init(APP_ROOT) ) {
_exit_html_fail('<h1>Invalid Application Configuration [ALB-015]</h1>', 500);
}
/**
* PostgreSQL Connection
*/
function _dbc() : \Edoceo\Radix\DB\SQL
{
static $dbc;
if (empty($dbc)) {
$cfg = \OpenTHC\Config::get('database/cre');
$dsn = sprintf('pgsql:application_name=openthc-cre;host=%s;dbname=%s', $cfg['hostname'], $cfg['database']);
$dbc = new \Edoceo\Radix\DB\SQL($dsn, $cfg['username'], $cfg['password']);
}
return $dbc;
}
/**
* Redis Connection
*/
function _rdb() : \Redis
{
static $rdb;
if (empty($rdb)) {
$cfg = \OpenTHC\Config::get('redis');
$rdb = new \Redis();
$rdb->connect($cfg['hostname']);
$rdb->select(intval($cfg['database']));
}
return $rdb;
}
/**
* Add your own Custom, Top-Level Functions/Includes Here
*/