-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdependencies.php
46 lines (44 loc) · 1.91 KB
/
dependencies.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
<?php
use CliFyi\ErrorHandler\ErrorHandler;
use CliFyi\Middleware\GoogleAnalyticsMiddleware;
use CliFyi\Service\CryptoCurrency\CryptoComparePriceFetcher;
use CliFyi\Service\Hash\HasherInterface;
use CliFyi\Service\Hash\HasherService;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\ClientInterface;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Predis\Client;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
use Psr\SimpleCache\CacheInterface;
use CliFyi\Cache\RedisAdapter;
return [
RequestInterface::class => \DI\get('request'),
ResponseInterface::class => \DI\get('response'),
Client::class => function () {
return new Client([
'scheme' => 'tcp',
'host' => getenv('REDIS_HOST'),
'port' => getenv('REDIS_PORT'),
]);
},
ClientInterface::class => \DI\object(HttpClient::class),
LoggerInterface::class => function () {
return (new Logger('Cli.Fyi Log'))
->pushHandler(new RotatingFileHandler(__DIR__ . '/../logs/logs.log', 30, Logger::INFO));
},
RedisAdapter::class => \DI\object(RedisAdapter::class)->constructor(\DI\get(Client::class)),
CacheInterface::class => \DI\object(RedisAdapter::class),
CryptoComparePriceFetcher::class => \DI\object()->constructor(\DI\get(HttpClient::class)),
'errorHandler' => \DI\object(ErrorHandler::class)
->constructor(\DI\get(LoggerInterface::class), getenv('DEBUG_MODE')),
'phpErrorHandler' => \DI\object(ErrorHandler::class)
->constructor(\DI\get(LoggerInterface::class), getenv('DEBUG_MODE')),
GoogleAnalyticsMiddleware::class => \DI\object()->constructor(
\DI\get(ClientInterface::class), \DI\get(LoggerInterface::class),
\DI\object(\CliFyi\Service\UuidGenerator::class), getenv('GOOGLE_ANALYTICS_ID')
),
HasherInterface::class => DI\object(HasherService::class)
];