phpstreamserver / symfony
Symfony bundle for PHPStreamServer
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Type:symfony-bundle
Requires
- php: >=8.2
- ext-pcntl: *
- ext-posix: *
- phpstreamserver/core: ^0.5
- phpstreamserver/http-server: ^0.5
- symfony/config: ^7.0
- symfony/dependency-injection: ^7.0
- symfony/dotenv: ^7.0
- symfony/http-kernel: ^7.0
- symfony/runtime: ^7.0
README
Symfony Bundle for PHPStreamServer
This bundle provides a PHPStreamServer integration with the Symfony framework to run your application in a highly efficient event-loop based runtime.
Getting started
Install
$ composer require phpstreamserver/symfony
Enable the bundle
// config/bundles.php return [ // ... PHPStreamServer\Symfony\PHPStreamServerBundle::class => ['all' => true], ];
Set PHPStreamServerRuntime as the application runtime
Use the APP_RUNTIME
environment variable or by specifying the extra.runtime.class
in composer.json
to change the Runtime class to PHPStreamServer\Symfony\PHPStreamServerRuntime
.
{ "require": { "...": "..." }, "extra": { "runtime": { "class": "PHPStreamServer\\Symfony\\PHPStreamServerRuntime" } } }
Create config/phpss.config.php file
<?php use PHPStreamServer\Core\ReloadStrategy\ExceptionReloadStrategy; use PHPStreamServer\Core\Server; use PHPStreamServer\Symfony\Worker\SymfonyHttpServerProcess; return static function (Server $server): void { $server->addWorker(new SymfonyHttpServerProcess( listen: '0.0.0.0:80', count: 1, reloadStrategies: [ new ExceptionReloadStrategy(), ], )); };
Create bin/phpss file
#!/usr/bin/env php <?php use App\Kernel; use PHPStreamServer\Symfony\ServerApplication; require_once \dirname(__DIR__) . '/vendor/autoload_runtime.php'; return new ServerApplication(static function (array $context) { return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); });
Create bin/console file
#!/usr/bin/env php <?php use App\Kernel; use PHPStreamServer\Symfony\ConsoleApplication; require_once \dirname(__DIR__) . '/vendor/autoload_runtime.php'; return new ConsoleApplication(static function (array $context) { return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); });
* Modifying the bin/console
file is essential to integrate console commands with PHPStreamServer—do not skip this step.
Start the server
$ bin/phpss start
Intergation with Monolog logger
Learn how to integrate your Symfony application with the Monolog logger.
Read more...