-
Notifications
You must be signed in to change notification settings - Fork 146
/
setup.php
33 lines (27 loc) · 925 Bytes
/
setup.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
<?php
define('CERTIFICATE_DIR', __DIR__ . '/certs/');
if (!class_exists("TypeError")) {
// Hack for PHP7 throwing type mismatches as TypeErrors rather than Mosquito\Exception
class TypeError extends Exception {}
}
$defaults = array(
'TEST_MQTT_HOST' => 'localhost',
'TEST_MQTT_PORT' => 1883,
'TEST_MQTT_TLS_PORT' => 8883,
'TEST_MQTT_TLS_CERT_PORT' => 8884,
'TEST_MQTT_TLS_PSK_PORT' => 8885,
);
foreach ($defaults as $index => $default) {
if (getenv($index)) {
define($index, getenv($index));
} else {
define($index, $default);
}
}
function errorHandler($errno, $errstr, $errfile, $errline) {
printf("Caught error %d (%s) in %s on line %d\n", $errno, $errstr, $errfile, $errline);
}
set_error_handler('errorHandler');
function writeException(Exception $e) {
printf("Caught %s with code %d and message: %s\n", get_class($e), $e->getCode(), $e->getMessage());
}