-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwooleConfiguration.php
More file actions
46 lines (41 loc) · 1.58 KB
/
SwooleConfiguration.php
File metadata and controls
46 lines (41 loc) · 1.58 KB
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
declare(strict_types=1);
namespace Lit\Runner\Swoole;
use Lit\Air\Configurator as C;
use Lit\Bolt\BoltApp;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Swoole\Http\Server;
use Zend\Diactoros\ResponseFactory;
/**
* swoole runner configuration class
*/
class SwooleConfiguration
{
/**
* Return default configuration for swoole runner.
*
* @return array
*/
public static function default()
{
return [
SwooleRunner::class => C::provideParameter([
Server::class => C::alias(SwooleRunner::class, 'server'),
RequestHandlerInterface::class => C::alias(SwooleRunner::class, 'handler'),
]),
C::join(SwooleRunner::class, 'handler') => C::alias(BoltApp::class),
C::join(SwooleRunner::class, 'server') => C::instance(Server::class, [
C::alias(SwooleRunner::class, 'server', 'host'),
C::alias(SwooleRunner::class, 'server', 'port'),
C::alias(SwooleRunner::class, 'server', 'mode'),
C::alias(SwooleRunner::class, 'server', 'type'),
]),
C::join(SwooleRunner::class, 'server', 'host') => $_ENV['HOST'] ?? 'localhost',
C::join(SwooleRunner::class, 'server', 'port') => $_ENV['PORT'] ?? '8080',
C::join(SwooleRunner::class, 'server', 'mode') => SWOOLE_PROCESS,
C::join(SwooleRunner::class, 'server', 'type') => SWOOLE_SOCK_TCP,
ResponseFactoryInterface::class => C::instance(ResponseFactory::class),
];
}
}