Skip to content

Commit dd55162

Browse files
committed
update readme
1 parent 50e08ae commit dd55162

File tree

2 files changed

+84
-35
lines changed

2 files changed

+84
-35
lines changed

README.md

Lines changed: 82 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
* PHP ^7.4|^8.0
1212
* Antidot Framework
13+
* DriftPHP Server
1314
* React Http
15+
* React Promises
1416
* Ramsey Uuid
1517

1618
## Description
@@ -74,44 +76,90 @@ $aggregator = new ConfigAggregator([
7476
return $aggregator->getMergedConfig();
7577
```
7678

77-
The create your React Http server
79+
Default Config:
7880

7981
```php
80-
#!/usr/bin/env php
8182
<?php
8283

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
8498

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)
116100

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
117110
```
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+

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"test": "phpunit --colors=always"
5656
},
5757
"config": {
58-
"sort-packages": true
58+
"sort-packages": true,
59+
"discard-changes": true
5960
},
6061
"extra": {
6162
"laminas": {

0 commit comments

Comments
 (0)