|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Antidot\React\Container\Config; |
|
6
|
|
|
|
|
7
|
|
|
use Antidot\Application\Http\Application; |
|
8
|
|
|
use Antidot\Application\Http\Middleware\Pipeline; |
|
9
|
|
|
use Antidot\Application\Http\Router; |
|
10
|
|
|
use Antidot\React\Container\ApplicationFactory; |
|
11
|
|
|
use Antidot\React\Container\EmitterFactory; |
|
12
|
|
|
use Antidot\React\Container\LoopFactory; |
|
13
|
|
|
use Antidot\React\Container\ReactHttpServerFactory; |
|
14
|
|
|
use Antidot\React\Container\SocketServerFactory; |
|
15
|
|
|
use Antidot\React\MiddlewarePipeline; |
|
16
|
|
|
use Antidot\React\ReactHttpServer; |
|
17
|
|
|
use Antidot\React\Router\ReactFastRouter; |
|
18
|
|
|
use Laminas\HttpHandlerRunner\Emitter\EmitterStack; |
|
19
|
|
|
use React\EventLoop\LoopInterface; |
|
20
|
|
|
use React\Socket\ServerInterface; |
|
21
|
|
|
|
|
22
|
|
|
class ConfigProvider |
|
23
|
|
|
{ |
|
24
|
|
|
public function __invoke(): array |
|
25
|
|
|
{ |
|
26
|
|
|
return [ |
|
27
|
|
|
'services' => [ |
|
28
|
|
|
Pipeline::class => MiddlewarePipeline::class, |
|
29
|
|
|
Router::class => ReactFastRouter::class, |
|
30
|
|
|
], |
|
31
|
|
|
'factories' => [ |
|
32
|
|
|
Application::class => ApplicationFactory::class, |
|
33
|
|
|
ServerInterface::class => SocketServerFactory::class, |
|
34
|
|
|
EmitterStack::class => EmitterFactory::class, |
|
35
|
|
|
LoopInterface::class => LoopFactory::class, |
|
36
|
|
|
ReactHttpServer::class => ReactHttpServerFactory::class, |
|
37
|
|
|
], |
|
38
|
|
|
'console' => [ |
|
39
|
|
|
'commands' => [ |
|
40
|
|
|
ReactHttpServer::NAME => ReactHttpServer::class, |
|
41
|
|
|
] |
|
42
|
|
|
], |
|
43
|
|
|
'react_http_server' => [ |
|
44
|
|
|
'uri' => '0.0.0.0:8080', |
|
45
|
|
|
'container_path' => 'config/container.php', |
|
46
|
|
|
'router_path' => 'router/routes.php', |
|
47
|
|
|
'middleware_path' => 'router/middleware.php', |
|
48
|
|
|
], |
|
49
|
|
|
]; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|