{"id":19327684,"url":"https://github.com/antidot-framework/react-framework","last_synced_at":"2025-06-14T02:39:39.640Z","repository":{"id":49597715,"uuid":"329995847","full_name":"antidot-framework/react-framework","owner":"antidot-framework","description":"This package allows running asynchronous PHP following the PSR-15 middleware standard approach.","archived":false,"fork":false,"pushed_at":"2021-11-28T18:26:43.000Z","size":60,"stargazers_count":8,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"2.x.x","last_synced_at":"2025-04-02T04:03:39.766Z","etag":null,"topics":["hacktoberfest","psr-15","psr-7","reactphp"],"latest_commit_sha":null,"homepage":"https://react.antidotfw.io/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antidot-framework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"kpicaza"}},"created_at":"2021-01-15T18:48:51.000Z","updated_at":"2023-01-17T13:01:53.000Z","dependencies_parsed_at":"2022-09-19T02:11:38.127Z","dependency_job_id":null,"html_url":"https://github.com/antidot-framework/react-framework","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":"kpicaza/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Freact-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Freact-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Freact-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antidot-framework%2Freact-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antidot-framework","download_url":"https://codeload.github.com/antidot-framework/react-framework/tar.gz/refs/heads/2.x.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250328088,"owners_count":21412555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","psr-15","psr-7","reactphp"],"created_at":"2024-11-10T02:18:09.659Z","updated_at":"2025-04-22T21:30:30.696Z","avatar_url":"https://github.com/antidot-framework.png","language":"PHP","funding_links":["https://github.com/sponsors/kpicaza"],"categories":[],"sub_categories":[],"readme":"# Antidot React Framework\n\n[![link-packagist](https://img.shields.io/packagist/v/antidot-fw/react-framework.svg?style=flat-square)](https://packagist.org/packages/antidot-fw/react-framework)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/antidot-framework/react-framework/badges/quality-score.png?b=2.x.x)](https://scrutinizer-ci.com/g/antidot-framework/react-framework/?branch=2.x.x)\n[![type-coverage](https://shepherd.dev/github/antidot-framework/react-framework/coverage.svg)](https://shepherd.dev/github/antidot-framework/react-framework)\n[![Code Coverage](https://scrutinizer-ci.com/g/antidot-framework/react-framework/badges/coverage.png?b=2.x.x)](https://scrutinizer-ci.com/g/antidot-framework/react-framework/?branch=2.x.x)\n[![Build Status](https://scrutinizer-ci.com/g/antidot-framework/react-framework/badges/build.png?b=2.x.x)](https://scrutinizer-ci.com/g/antidot-framework/react-framework/build-status/2.x.x)\n\n## Requirements\n\n* PHP ^7.4|^8.0\n* [Antidot Framework](https://antidotfw.io)\n* [DriftPHP Server](https://github.com/driftphp/server)  \n* [React Http](https://github.com/reactphp/http)\n* [React Promises](https://github.com/reactphp/promise)\n* [Ramsey Uuid](https://github.com/ramsey/uuid)\n\n## Description\n\nThis package allows running asynchronous PHP following PSR-15 middleware standard approach.\n\n## Install\n\nThe preferred way to install this library is using the `reactive-antidot-starter` project.\n\n```bash\ncomposer create-project antidot-fw/reactive-antidot-starter\n```\n\n\u003e [Antidot Framework Reactive Starter](https://github.com/antidot-framework/reactive-antidot-starter)\n\nTo install it on a existing Antidot Framework Project installation we need to tweak some configurations and replace or create new `index.php` file.\n\n```bash\ncomposer require antidot-fw/react-framework\n```\n\n## Config\n\n* Disable LaminasRequest Handler Runner\n* Load Antidot React Config Provider after Antidot Framework provider\n\nExample config from starter project\n```php\n\u003c?php\n// config/config.php\n\ndeclare(strict_types=1);\n\nuse Antidot\\DevTools\\Container\\Config\\ConfigProvider as DevToolsConfigProvider;\nuse Antidot\\SymfonyConfigTranslator\\Container\\Config\\ConfigAggregator;\nuse Antidot\\Yaml\\YamlConfigProvider;\nuse Laminas\\ConfigAggregator\\ArrayProvider;\nuse Laminas\\ConfigAggregator\\PhpFileProvider;\n\n// To enable or disable caching, set the `ConfigAggregator::ENABLE_CACHE` boolean in\n// `config/autoload/local.php`.\n$cacheConfig = [\n    'config_cache_path' =\u003e 'var/cache/config-cache.php',\n];\n\n$aggregator = new ConfigAggregator([\n    \\WShafer\\PSR11MonoLog\\ConfigProvider::class,\n    \\Antidot\\Event\\Container\\Config\\ConfigProvider::class,\n    \\Antidot\\Logger\\Container\\Config\\ConfigProvider::class,\n    \\Antidot\\Cli\\Container\\Config\\ConfigProvider::class,\n    \\Antidot\\Fast\\Router\\Container\\Config\\ConfigProvider::class,\n    \\Antidot\\Container\\Config\\ConfigProvider::class,\n    \\Antidot\\React\\Container\\Config\\ConfigProvider::class,\n    class_exists(DevToolsConfigProvider::class) ? DevToolsConfigProvider::class : fn() =\u003e [],\n    new PhpFileProvider(realpath(__DIR__).'/services/{{,*.}prod,{,*.}local,{,*.}dev}.php'),\n    new YamlConfigProvider(realpath(__DIR__).'/services/{{,*.}prod,{,*.}local,{,*.}dev}.yaml'),\n    new ArrayProvider($cacheConfig),\n], $cacheConfig['config_cache_path']);\n\nreturn $aggregator-\u003egetMergedConfig();\n```\n\nDefault Config:\n\n```php\n\u003c?php\n\n$config = [\n    'server' =\u003e [\n        'host' =\u003e '0.0.0.0',\n        'port' =\u003e 5555,\n        'buffer_size' =\u003e 4096,\n        'max_concurrency' =\u003e 100,\n        'workers' =\u003e 1,\n        'static_folder' =\u003e 'public'\n    ]\n]\n\n```\n\n## Usage\n\nIt allows executing promises inside PSR-15 and PSR-7 Middlewares and request handlers\n\n### PSR-15 Middleware\n\n```php\n\u003c?php\ndeclare(strict_types = 1);\n\nnamespace App;\n\nuse Antidot\\React\\PromiseResponse;\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Server\\MiddlewareInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\n\nclass SomeMiddleware implements MiddlewareInterface\n{\n    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n    {\n        return new PromiseResponse(\n            resolve($request)\n                -\u003ethen(static fn(ServerrequestInsterface $request) =\u003e $handler-\u003ehandle($request))\n        );\n    }\n}\n```\n\n### PSR-7 Request Handler\n\n```php\n\u003c?php\ndeclare(strict_types = 1);\n\nnamespace App;\n\nuse Antidot\\React\\PromiseResponse;\nuse Psr\\Http\\Message\\ResponseInterface;\nuse Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\n\nclass SomeMiddleware implements RequestHandlerInterface\n{\n    public function process(ServerRequestInterface $request): ResponseInterface\n    {\n        return resolve($request)-\u003ethen(\n            function(ServerrequestInterface $request): ResponseInterface {\n                return new Response('Hello World!!!');\n            }\n        );;\n    }\n}\n```\n\n## Server\n\nTwo 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)\n\n* `server:run`: Run Drift HTTP Server\n* `server:watch`: Watch Drift HTTP Server for development purposes\n\n```bash\n$ bin/console\n...\n server\n  server:run               Run Drift HTTP Server\n  server:watch             Watch Drift HTTP Server for development purposes\n```\n\n```bash\n$ bin/console server:run -h\nDescription:\n  Run Drift HTTP Server\n\nUsage:\n  server:run [options] [--] [\u003cpath\u003e]\n\nArguments:\n  path                                             The server will start listening to this address [default: \"0.0.0.0:5555\"]\n\nOptions:\n      --static-folder[=STATIC-FOLDER]              Static folder path [default: \"public\"]\n      --no-static-folder                           Disable static folder\n      --debug                                      Enable debug\n      --no-header                                  Disable the header\n      --no-cookies                                 Disable cookies\n      --no-file-uploads                            Disable file uploads\n      --concurrent-requests[=CONCURRENT-REQUESTS]  Limit of concurrent requests [default: 100]\n      --request-body-buffer[=REQUEST-BODY-BUFFER]  Limit of the buffer used for the Request body. In KiB. [default: 4096]\n      --adapter[=ADAPTER]                          Server Adapter [default: \"Antidot\\React\\DriftKernelAdapter\"]\n      --allowed-loop-stops[=ALLOWED-LOOP-STOPS]    Number of allowed loop stops [default: 0]\n      --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]\n  -q, --quiet                                      Do not output any message\n\n```\n\n```bash\n$ bin/console server:watch -h\nDescription:\n  Watch Drift HTTP Server for development purposes\n\nUsage:\n  server:watch [options] [--] [\u003cpath\u003e]\n\nArguments:\n  path                                             The server will start listening to this address [default: \"0.0.0.0:5555\"]\n\nOptions:\n      --static-folder[=STATIC-FOLDER]              Static folder path [default: \"public\"]\n      --no-static-folder                           Disable static folder\n      --debug                                      Enable debug\n      --no-header                                  Disable the header\n      --no-cookies                                 Disable cookies\n      --no-file-uploads                            Disable file uploads\n      --concurrent-requests[=CONCURRENT-REQUESTS]  Limit of concurrent requests [default: 512]\n      --request-body-buffer[=REQUEST-BODY-BUFFER]  Limit of the buffer used for the Request body. In KiB. [default: 2048]\n      --adapter[=ADAPTER]                          Server Adapter [default: \"drift\"]\n      --allowed-loop-stops[=ALLOWED-LOOP-STOPS]    Number of allowed loop stops [default: 0]\n      --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]\n  -q, --quiet                                      Do not output any message\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantidot-framework%2Freact-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantidot-framework%2Freact-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantidot-framework%2Freact-framework/lists"}