mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-05 10:34:55 +02:00
refactor: introduce DI container (#4238)
* refactor: introduce DI container * add bin/test
This commit is contained in:
parent
e010fd4d52
commit
58544cd61a
18 changed files with 231 additions and 89 deletions
|
@ -17,11 +17,8 @@ if (file_exists(__DIR__ . '/../config.ini.php')) {
|
|||
}
|
||||
Configuration::loadConfiguration($config, getenv());
|
||||
|
||||
$logger = new SimpleLogger('rssbridge');
|
||||
$container = require __DIR__ . '/../lib/dependencies.php';
|
||||
|
||||
$logger->addHandler(new StreamHandler('php://stderr', Logger::INFO));
|
||||
|
||||
$cacheFactory = new CacheFactory($logger);
|
||||
$cache = $cacheFactory->create();
|
||||
$cache = $container['cache'];
|
||||
|
||||
$cache->clear();
|
||||
|
|
|
@ -17,11 +17,8 @@ if (file_exists(__DIR__ . '/../config.ini.php')) {
|
|||
}
|
||||
Configuration::loadConfiguration($config, getenv());
|
||||
|
||||
$logger = new SimpleLogger('rssbridge');
|
||||
$container = require __DIR__ . '/../lib/dependencies.php';
|
||||
|
||||
$logger->addHandler(new StreamHandler('php://stderr', Logger::INFO));
|
||||
|
||||
$cacheFactory = new CacheFactory($logger);
|
||||
$cache = $cacheFactory->create();
|
||||
$cache = $container['cache'];
|
||||
|
||||
$cache->prune();
|
||||
|
|
29
bin/test
Executable file
29
bin/test
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Add log records to all three levels (for testing purposes)
|
||||
*/
|
||||
|
||||
require __DIR__ . '/../lib/bootstrap.php';
|
||||
|
||||
$config = [];
|
||||
if (file_exists(__DIR__ . '/../config.ini.php')) {
|
||||
$config = parse_ini_file(__DIR__ . '/../config.ini.php', true, INI_SCANNER_TYPED);
|
||||
if (!$config) {
|
||||
http_response_code(500);
|
||||
exit("Error parsing config.ini.php\n");
|
||||
}
|
||||
}
|
||||
Configuration::loadConfiguration($config, getenv());
|
||||
|
||||
$container = require __DIR__ . '/../lib/dependencies.php';
|
||||
|
||||
/** @var Logger $logger */
|
||||
$logger = $container['logger'];
|
||||
|
||||
$logger->debug('This is a test debug message');
|
||||
|
||||
$logger->info('This is a test info message');
|
||||
|
||||
$logger->error('This is a test error message');
|
Loading…
Add table
Add a link
Reference in a new issue