https://github.com/antidot-framework/reactive-antidot-starter
Reactive Antidot Framework Apllication Starter
https://github.com/antidot-framework/reactive-antidot-starter
composer psr-11 psr-15 psr-7 react-php reactive-antidot-framework
Last synced: 5 months ago
JSON representation
Reactive Antidot Framework Apllication Starter
- Host: GitHub
- URL: https://github.com/antidot-framework/reactive-antidot-starter
- Owner: antidot-framework
- License: bsd-2-clause
- Created: 2019-11-23T19:16:27.000Z (over 5 years ago)
- Default Branch: 2.x.x
- Last Pushed: 2022-11-07T23:09:21.000Z (over 2 years ago)
- Last Synced: 2024-08-03T15:05:05.795Z (9 months ago)
- Topics: composer, psr-11, psr-15, psr-7, react-php, reactive-antidot-framework
- Language: PHP
- Homepage: https://antidotfw.io
- Size: 67.4 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Reactive Antidot Framework
=================[](https://packagist.org/packages/antidot-fw/reactive-starter)
This framework is based on concepts and components of other open source software, especially
[Zend Expressive](https://docs.zendframework.com/zend-expressive/),
[Zend Stratigillity](https://docs.zendframework.com/zend-stratigility/),
[Recoil](https://github.com/recoilphp/recoil) and [React PHP](https://reactphp.org/).## Installation
Install a project using [composer](https://getcomposer.org/download/) package manager:
````bash
composer create-project antidot-fw/reactive-starter dev
mv dev/.* dev/* ./ && rmdir dev
bin/console server:run
````Open your browser localhost on port `5555` and you will see the [DriftPHP Server](https://github.com/driftphp/server) up and running.
## Config
### Server Config
Default config
```yaml
parameters:
server:
host: '0.0.0.0'
port: '5555'
max_concurrency: 100
buffer_size: 4096
workers: 4```
### Development Mode
To run it in dev mode you can run `config:development-mode` command
````bash
bin/console config:development-mode
````Or you can do it by hand renaming from `config/services/dependencies.dev.yaml.dist` to `config/services/dependencies.dev.yaml`
````bash
mv config/services/dependencies.dev.yaml.dist config/services/dependencies.dev.yaml
````### Hot Code Reloading
```bash
composer require seregazhuk/php-watcher --dev
```You can use [Php whatcher](https://github.com/seregazhuk/php-watcher) with composer for more friendly development.
````bash
bin/console server:watch
````
Open another console and check the built-in Cli tool
````bash
bin/console
````
## Async Usage
It allows executing promises inside PSR-15 and PSR-7 Middlewares and request handlers
### PSR-15 Middleware
```php
then(static fn(ServerrequestInsterface $request) => $handler->handle($request))
);
}
}
```### PSR-7 Request Handler
```php
then(
function(ServerrequestInterface $request): ResponseInterface {
return new Response('Hello World!!!');
}
);;
}
}
```## Classic Usage
It allows executing classic PSR-15 middleware and request handler:
### PSR-15 Middleware
```php
handle($request);
}
}
```### PSR-7 Request Handler
```php
ab -n 40000 -c 64 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 127.0.0.1 (be patient)
Server Software: ReactPHP/1
Server Hostname: 127.0.0.1
Server Port: 8080Document Path: /
Document Length: 96 bytesConcurrency Level: 64
Time taken for tests: 16.201 seconds
Complete requests: 40000
Failed requests: 0
Total transferred: 8960000 bytes
HTML transferred: 3840000 bytes
Requests per second: 2468.93 [#/sec] (mean)
Time per request: 25.922 [ms] (mean)
Time per request: 0.405 [ms] (mean, across all concurrent requests)
Transfer rate: 540.08 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 15 26 1.4 25 33
Waiting: 15 26 1.4 25 33
Total: 16 26 1.4 25 33Percentage of the requests served within a certain time (ms)
50% 25
66% 25
75% 26
80% 26
90% 27
95% 29
98% 31
99% 32
100% 33 (longest request)```
using wrk:
```bash
> wrk -t8 -c64 -d15s http://127.0.0.1:8080/ [95ba8e6]
Running 15s test @ http://127.0.0.1:8080/
8 threads and 64 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 26.14ms 1.44ms 34.63ms 92.76%
Req/Sec 306.84 24.52 373.00 81.17%
36670 requests in 15.04s, 8.50MB read
Requests/sec: 2437.45
Transfer/sec: 578.42KB
```See ranking in [The Benchmarker - Web Framework](https://github.com/the-benchmarker/web-frameworks) project.