|
10 | 10 |
|
11 | 11 | * PHP ^7.4|^8.0 |
12 | 12 | * Antidot Framework |
| 13 | +* DriftPHP Server |
13 | 14 | * React Http |
| 15 | +* React Promises |
14 | 16 | * Ramsey Uuid |
15 | 17 |
|
16 | 18 | ## Description |
@@ -74,44 +76,90 @@ $aggregator = new ConfigAggregator([ |
74 | 76 | return $aggregator->getMergedConfig(); |
75 | 77 | ``` |
76 | 78 |
|
77 | | -The create your React Http server |
| 79 | +Default Config: |
78 | 80 |
|
79 | 81 | ```php |
80 | | -#!/usr/bin/env php |
81 | 82 | <?php |
82 | 83 |
|
83 | | -declare(strict_types=1); |
| 84 | +$config = [ |
| 85 | + 'server' => [ |
| 86 | + 'host' => '0.0.0.0', |
| 87 | + 'port' => 5555, |
| 88 | + 'buffer_size' => 4096, |
| 89 | + 'max_concurrency' => 100, |
| 90 | + 'workers' => 1, |
| 91 | + 'static_folder' => 'public' |
| 92 | + ] |
| 93 | +] |
| 94 | + |
| 95 | +``` |
| 96 | + |
| 97 | +### Usage |
84 | 98 |
|
85 | | -use Antidot\Application\Http\Application; |
86 | | -use Antidot\React\Child; |
87 | | -use Psr\Log\LoggerInterface; |
88 | | -use React\EventLoop\LoopInterface; |
89 | | -use React\Http\Server; |
90 | | -use React\Socket\Server as Socket; |
91 | | - |
92 | | -require 'vendor/autoload.php'; |
93 | | - |
94 | | -call_user_func(static function () { |
95 | | - $container = require 'config/container.php'; |
96 | | - $application = $container->get(Application::class); |
97 | | - (require 'router/middleware.php')($application, $container); |
98 | | - (require 'router/routes.php')($application, $container); |
99 | | - |
100 | | - $loop = $container->get(LoopInterface::class); |
101 | | - Child::fork( |
102 | | - shell_exec('nproc') ? (int)shell_exec('nproc') : 16, |
103 | | - static function () use ($container) { |
104 | | - $server = $container->get(Server::class); |
105 | | - $server->on('error', static function ($err) use ($container) { |
106 | | - $logger = $container->get(LoggerInterface::class); |
107 | | - $logger->critical($err); |
108 | | - }); |
109 | | - |
110 | | - $socket = $container->get(Socket::class); |
111 | | - $server->listen($socket); |
112 | | - }); |
113 | | - |
114 | | - $loop->run(); |
115 | | -}); |
| 99 | +Two new commands will be added to the Antidot Framework CLI tool, to allow running the application on top of [Drift server](https://driftphp.io/#/?id=the-server) |
116 | 100 |
|
| 101 | +* `server:run`: Run Drift HTTP Server |
| 102 | +* `server:watch`: Watch Drift HTTP Server for development purposes |
| 103 | + |
| 104 | +```bash |
| 105 | +$ bin/console |
| 106 | +... |
| 107 | + server |
| 108 | + server:run Run Drift HTTP Server |
| 109 | + server:watch Watch Drift HTTP Server for development purposes |
117 | 110 | ``` |
| 111 | + |
| 112 | +```bash |
| 113 | +$ bin/console server:run -h |
| 114 | +Description: |
| 115 | + Run Drift HTTP Server |
| 116 | + |
| 117 | +Usage: |
| 118 | + server:run [options] [--] [<path>] |
| 119 | + |
| 120 | +Arguments: |
| 121 | + path The server will start listening to this address [default: "0.0.0.0:5555"] |
| 122 | + |
| 123 | +Options: |
| 124 | + --static-folder[=STATIC-FOLDER] Static folder path [default: "public"] |
| 125 | + --no-static-folder Disable static folder |
| 126 | + --debug Enable debug |
| 127 | + --no-header Disable the header |
| 128 | + --no-cookies Disable cookies |
| 129 | + --no-file-uploads Disable file uploads |
| 130 | + --concurrent-requests[=CONCURRENT-REQUESTS] Limit of concurrent requests [default: 100] |
| 131 | + --request-body-buffer[=REQUEST-BODY-BUFFER] Limit of the buffer used for the Request body. In KiB. [default: 4096] |
| 132 | + --adapter[=ADAPTER] Server Adapter [default: "Antidot\React\DriftKernelAdapter"] |
| 133 | + --allowed-loop-stops[=ALLOWED-LOOP-STOPS] Number of allowed loop stops [default: 0] |
| 134 | + --workers[=WORKERS] Number of workers. Use -1 to get as many workers as physical thread available for your system. Maximum of 128 workers. Option disabled for watch command. [default: 16] |
| 135 | + -q, --quiet Do not output any message |
| 136 | + |
| 137 | +``` |
| 138 | + |
| 139 | +```bash |
| 140 | +$ bin/console server:watch -h |
| 141 | +Description: |
| 142 | + Watch Drift HTTP Server for development purposes |
| 143 | + |
| 144 | +Usage: |
| 145 | + server:watch [options] [--] [<path>] |
| 146 | + |
| 147 | +Arguments: |
| 148 | + path The server will start listening to this address [default: "0.0.0.0:5555"] |
| 149 | + |
| 150 | +Options: |
| 151 | + --static-folder[=STATIC-FOLDER] Static folder path [default: "public"] |
| 152 | + --no-static-folder Disable static folder |
| 153 | + --debug Enable debug |
| 154 | + --no-header Disable the header |
| 155 | + --no-cookies Disable cookies |
| 156 | + --no-file-uploads Disable file uploads |
| 157 | + --concurrent-requests[=CONCURRENT-REQUESTS] Limit of concurrent requests [default: 512] |
| 158 | + --request-body-buffer[=REQUEST-BODY-BUFFER] Limit of the buffer used for the Request body. In KiB. [default: 2048] |
| 159 | + --adapter[=ADAPTER] Server Adapter [default: "drift"] |
| 160 | + --allowed-loop-stops[=ALLOWED-LOOP-STOPS] Number of allowed loop stops [default: 0] |
| 161 | + --workers[=WORKERS] Number of workers. Use -1 to get as many workers as physical thread available for your system. Maximum of 128 workers. Option disabled for watch command. [default: 1] |
| 162 | + -q, --quiet Do not output any message |
| 163 | + |
| 164 | +``` |
| 165 | + |
0 commit comments