@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $handle = @fopen($config_path, 'r'); |
| 12 | 12 | if ($handle === false) { |
| 13 | - throw new RuntimeException("Could not load config"); |
|
| 13 | + throw new RuntimeException("Could not load config"); |
|
| 14 | 14 | } |
| 15 | 15 | $config = fread($handle, filesize($config_path)); |
| 16 | 16 | fclose($handle); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $config = json_decode($config); |
| 19 | 19 | $last_json_error = json_last_error(); |
| 20 | 20 | if ($last_json_error !== JSON_ERROR_NONE) { |
| 21 | - throw new RuntimeException("Could not parse config - JSON error detected"); |
|
| 21 | + throw new RuntimeException("Could not parse config - JSON error detected"); |
|
| 22 | 22 | } |
| 23 | 23 | $container['config'] = $config; |
| 24 | 24 | |
@@ -26,64 +26,64 @@ discard block |
||
| 26 | 26 | // timezones are fun |
| 27 | 27 | date_default_timezone_set('America/Phoenix'); // todo - belongs in configuration |
| 28 | 28 | $container['default_timezone'] = function ($c) { |
| 29 | - return new DateTimeZone('America/Phoenix'); |
|
| 29 | + return new DateTimeZone('America/Phoenix'); |
|
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | // configure the db connections holder |
| 34 | 34 | $db_connections = new Aura\Sql\ConnectionLocator(); |
| 35 | 35 | $db_connections->setDefault(function () use ($config) { |
| 36 | - $connection = $config->database->slave; |
|
| 37 | - return new Aura\Sql\ExtendedPdo( |
|
| 38 | - "mysql:host={$connection->host}", |
|
| 39 | - $connection->user, |
|
| 40 | - $connection->password |
|
| 41 | - ); |
|
| 36 | + $connection = $config->database->slave; |
|
| 37 | + return new Aura\Sql\ExtendedPdo( |
|
| 38 | + "mysql:host={$connection->host}", |
|
| 39 | + $connection->user, |
|
| 40 | + $connection->password |
|
| 41 | + ); |
|
| 42 | 42 | }); |
| 43 | 43 | $db_connections->setWrite('master', function () use ($config) { |
| 44 | - $connection = $config->database->master; |
|
| 45 | - return new Aura\Sql\ExtendedPdo( |
|
| 46 | - "mysql:host={$connection->host}", |
|
| 47 | - $connection->user, |
|
| 48 | - $connection->password |
|
| 49 | - ); |
|
| 44 | + $connection = $config->database->master; |
|
| 45 | + return new Aura\Sql\ExtendedPdo( |
|
| 46 | + "mysql:host={$connection->host}", |
|
| 47 | + $connection->user, |
|
| 48 | + $connection->password |
|
| 49 | + ); |
|
| 50 | 50 | }); |
| 51 | 51 | $db_connections->setRead('slave', function () use ($config) { |
| 52 | - $connection = $config->database->slave; |
|
| 53 | - $pdo = new Aura\Sql\ExtendedPdo( |
|
| 54 | - "mysql:host={$connection->host}", |
|
| 55 | - $connection->user, |
|
| 56 | - $connection->password |
|
| 57 | - ); |
|
| 58 | - |
|
| 59 | - $profiler = new Aura\Sql\Profiler(); |
|
| 60 | - $profiler->setActive(true); |
|
| 61 | - $pdo->setProfiler($profiler); |
|
| 62 | - |
|
| 63 | - return $pdo; |
|
| 52 | + $connection = $config->database->slave; |
|
| 53 | + $pdo = new Aura\Sql\ExtendedPdo( |
|
| 54 | + "mysql:host={$connection->host}", |
|
| 55 | + $connection->user, |
|
| 56 | + $connection->password |
|
| 57 | + ); |
|
| 58 | + |
|
| 59 | + $profiler = new Aura\Sql\Profiler(); |
|
| 60 | + $profiler->setActive(true); |
|
| 61 | + $pdo->setProfiler($profiler); |
|
| 62 | + |
|
| 63 | + return $pdo; |
|
| 64 | 64 | }); |
| 65 | 65 | $container['db_connection_locator'] = $db_connections; |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | // setup mail handler |
| 69 | 69 | $container['mail'] = $container->factory(function ($c) { |
| 70 | - return (new Jacobemerick\Archangel\Archangel())->setLogger($c['logger']); |
|
| 70 | + return (new Jacobemerick\Archangel\Archangel())->setLogger($c['logger']); |
|
| 71 | 71 | }); |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | // setup the logger |
| 75 | 75 | $container['setup_logger'] = $container->protect(function ($name) use ($container) { |
| 76 | - $logger = new Monolog\Logger($name); |
|
| 76 | + $logger = new Monolog\Logger($name); |
|
| 77 | 77 | |
| 78 | - $logPath = __DIR__ . "/../logs/{$name}.log"; |
|
| 79 | - $streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO); |
|
| 80 | - $streamHandler->setFormatter( |
|
| 81 | - new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n") |
|
| 82 | - ); |
|
| 83 | - $logger->pushHandler($streamHandler); |
|
| 78 | + $logPath = __DIR__ . "/../logs/{$name}.log"; |
|
| 79 | + $streamHandler = new Monolog\Handler\StreamHandler($logPath, Monolog\Logger::INFO); |
|
| 80 | + $streamHandler->setFormatter( |
|
| 81 | + new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n") |
|
| 82 | + ); |
|
| 83 | + $logger->pushHandler($streamHandler); |
|
| 84 | 84 | |
| 85 | - Monolog\ErrorHandler::register($logger); |
|
| 86 | - $container['logger'] = $logger; |
|
| 85 | + Monolog\ErrorHandler::register($logger); |
|
| 86 | + $container['logger'] = $logger; |
|
| 87 | 87 | }); |
| 88 | 88 | |
| 89 | 89 | |