zolex / reactphp-bundle
ReactPHP Bundle for Symfony
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.1
- ext-fileinfo: *
- nyholm/psr7: ^1.8
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
- react/http: ^1.11
- symfony/config: ^6.4|^7.0
- symfony/dependency-injection: ^6.4|^7.0
- symfony/dotenv: ^6.4|^7.0
- symfony/http-kernel: ^6.4|^7.0
- symfony/psr-http-message-bridge: ^6.4|^7.0
- symfony/routing: ^6.4|^7.0
- symfony/runtime: ^6.4|^7.0
Requires (Dev)
- symfony/framework-bundle: ^6.4|^7.0
README
A Symfony Bundle providing a Runtime for ReactPHP, a PSR-17 Kernel and a Router to serve assets.
Turn any Symfony project into a "self-serving" application, no traditional webserver required.
Installation
composer require zolex/reactphp-bundle
Configuration
To run your symfony application using the ReactPHP server. You need to modify the default public/index.php
(or create a new file like app.php
) with the following content.
<?php use App\Kernel; use Zolex\ReactPhpBundle\Kernel\KernelPsr17Adapter; require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; return function (array $context) { return new KernelPsr17Adapter(new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG'])); };
Assets
To allow serving assets from the public directory through ReactPHP, add this file to your project config/routes/react_bundle.yaml
reactphp_bundle: type: reactphp_bundle resource: .
By default, only files in the public/bundles
directory are served (like Swagger-UI in API-Platform).
Additional directories and files can be registered in the bundle config at config/bundles/zolex_react_php.yaml
:
zolex_react_php: asset_paths: - /bundles/ - /custom-dir/ - /single-file.js - /another/single/file.css
Start the server
APP_RUNTIME="Zolex\\ReactPhpBundle\\Runtime\\ReactPhpRuntime" php public/index.php
For a very basic docker example, check the Dockerfile in the docs folder.