From c6e0d903ccbdc8cd495e4eea247500509d154cda Mon Sep 17 00:00:00 2001 From: Koldo Picaza Date: Tue, 2 Feb 2021 19:56:58 +0100 Subject: [PATCH] create docs page --- README.md | 62 ++++++++++++- docs/.nojekyll | 0 docs/README.md | 221 +++++++++++++++++++++++++++++++++++++++++++++ docs/_coverpage.md | 6 ++ docs/index.html | 54 +++++++++++ 5 files changed, 340 insertions(+), 3 deletions(-) create mode 100644 docs/.nojekyll create mode 100644 docs/README.md create mode 100644 docs/_coverpage.md create mode 100644 docs/index.html diff --git a/README.md b/README.md index 648f633..3ee1232 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ The preferred way to install this library is using the `reactive-antidot-starter composer create-project antidot-fw/reactive-antidot-starter ``` -> [Reactive Antidot Framework](https://github.com/antidot-framework/reactive-antidot-starter) +> [Antidot Framework Reactive Starter](https://github.com/antidot-framework/reactive-antidot-starter) To install it on a existing Antidot Framework Project installation we need to tweak some configurations and replace or create new `index.php` file. @@ -35,7 +35,7 @@ To install it on a existing Antidot Framework Project installation we need to tw composer require antidot-fw/react-framework ``` -### Config +## Config * Disable LaminasRequest Handler Runner * Load Antidot React Config Provider after Antidot Framework provider @@ -94,7 +94,63 @@ $config = [ ``` -### Usage +## 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!!!'); + } + );; + } +} +``` + +## Server 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) diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..3ee1232 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,221 @@ +# Antidot React Framework + +[![link-packagist](https://img.shields.io/packagist/v/antidot-fw/react-framework.svg?style=flat-square)](https://packagist.org/packages/antidot-fw/react-framework) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/antidot-framework/react-framework/badges/quality-score.png?b=0.0.x)](https://scrutinizer-ci.com/g/antidot-framework/react-framework/?branch=0.0.x) +[![type-coverage](https://shepherd.dev/github/antidot-framework/react-framework/coverage.svg)](https://shepherd.dev/github/antidot-framework/react-framework) +[![Code Coverage](https://scrutinizer-ci.com/g/antidot-framework/react-framework/badges/coverage.png?b=0.0.x)](https://scrutinizer-ci.com/g/antidot-framework/react-framework/?branch=0.0.x) +[![Build Status](https://scrutinizer-ci.com/g/antidot-framework/react-framework/badges/build.png?b=0.0.x)](https://scrutinizer-ci.com/g/antidot-framework/react-framework/build-status/0.0.x) + +## Requirements: + +* PHP ^7.4|^8.0 +* Antidot Framework +* DriftPHP Server +* React Http +* React Promises +* Ramsey Uuid + +## Description + +This package allows running both common synchronous and modern asynchronous PHP following PSR-15 middleware standard approach. + +## Install + +The preferred way to install this library is using the `reactive-antidot-starter` project. + +```bash +composer create-project antidot-fw/reactive-antidot-starter +``` + +> [Antidot Framework Reactive Starter](https://github.com/antidot-framework/reactive-antidot-starter) + +To install it on a existing Antidot Framework Project installation we need to tweak some configurations and replace or create new `index.php` file. + +```bash +composer require antidot-fw/react-framework +``` + +## Config + +* Disable LaminasRequest Handler Runner +* Load Antidot React Config Provider after Antidot Framework provider + +Example config from starter project +```php + 'var/cache/config-cache.php', +]; + +$aggregator = new ConfigAggregator([ + \WShafer\PSR11MonoLog\ConfigProvider::class, + \Antidot\Event\Container\Config\ConfigProvider::class, + \Antidot\Logger\Container\Config\ConfigProvider::class, + \Antidot\Cli\Container\Config\ConfigProvider::class, + \Antidot\Fast\Router\Container\Config\ConfigProvider::class, + \Antidot\Container\Config\ConfigProvider::class, + \Antidot\React\Container\Config\ConfigProvider::class, + class_exists(DevToolsConfigProvider::class) ? DevToolsConfigProvider::class : fn() => [], + new PhpFileProvider(realpath(__DIR__).'/services/{{,*.}prod,{,*.}local,{,*.}dev}.php'), + new YamlConfigProvider(realpath(__DIR__).'/services/{{,*.}prod,{,*.}local,{,*.}dev}.yaml'), + new ArrayProvider($cacheConfig), +], $cacheConfig['config_cache_path']); + +return $aggregator->getMergedConfig(); +``` + +Default Config: + +```php + [ + 'host' => '0.0.0.0', + 'port' => 5555, + 'buffer_size' => 4096, + 'max_concurrency' => 100, + 'workers' => 1, + 'static_folder' => 'public' + ] +] + +``` + +## 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!!!'); + } + );; + } +} +``` + +## Server + +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) + +* `server:run`: Run Drift HTTP Server +* `server:watch`: Watch Drift HTTP Server for development purposes + +```bash +$ bin/console +... + server + server:run Run Drift HTTP Server + server:watch Watch Drift HTTP Server for development purposes +``` + +```bash +$ bin/console server:run -h +Description: + Run Drift HTTP Server + +Usage: + server:run [options] [--] [] + +Arguments: + path The server will start listening to this address [default: "0.0.0.0:5555"] + +Options: + --static-folder[=STATIC-FOLDER] Static folder path [default: "public"] + --no-static-folder Disable static folder + --debug Enable debug + --no-header Disable the header + --no-cookies Disable cookies + --no-file-uploads Disable file uploads + --concurrent-requests[=CONCURRENT-REQUESTS] Limit of concurrent requests [default: 100] + --request-body-buffer[=REQUEST-BODY-BUFFER] Limit of the buffer used for the Request body. In KiB. [default: 4096] + --adapter[=ADAPTER] Server Adapter [default: "Antidot\React\DriftKernelAdapter"] + --allowed-loop-stops[=ALLOWED-LOOP-STOPS] Number of allowed loop stops [default: 0] + --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] + -q, --quiet Do not output any message + +``` + +```bash +$ bin/console server:watch -h +Description: + Watch Drift HTTP Server for development purposes + +Usage: + server:watch [options] [--] [] + +Arguments: + path The server will start listening to this address [default: "0.0.0.0:5555"] + +Options: + --static-folder[=STATIC-FOLDER] Static folder path [default: "public"] + --no-static-folder Disable static folder + --debug Enable debug + --no-header Disable the header + --no-cookies Disable cookies + --no-file-uploads Disable file uploads + --concurrent-requests[=CONCURRENT-REQUESTS] Limit of concurrent requests [default: 512] + --request-body-buffer[=REQUEST-BODY-BUFFER] Limit of the buffer used for the Request body. In KiB. [default: 2048] + --adapter[=ADAPTER] Server Adapter [default: "drift"] + --allowed-loop-stops[=ALLOWED-LOOP-STOPS] Number of allowed loop stops [default: 0] + --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] + -q, --quiet Do not output any message + +``` + diff --git a/docs/_coverpage.md b/docs/_coverpage.md new file mode 100644 index 0000000..2ef058c --- /dev/null +++ b/docs/_coverpage.md @@ -0,0 +1,6 @@ +# [Antidot Framework](#Antidot-React-Framework) + +> *PSR Compatible async full featured Framework* + +*[Start on github](https://github.com/antidot-framework/react-framework)* +*[Getting Started](/#Antidot-React-Framework)* diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..7fa6c1f --- /dev/null +++ b/docs/index.html @@ -0,0 +1,54 @@ + + + + + Antidot Framework Reactive Starter + + + + + + + + + + + + + + + +
+ + + + + + + + + +