This bundle provides a PHPStreamServer integration with the Symfony framework to run your application in a highly efficient event-loop based runtime.
$ composer require phpstreamserver/symfony
// config/bundles.php
return [
// ...
PHPStreamServer\Symfony\PHPStreamServerBundle::class => ['all' => true],
];
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"
}
}
}
<?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(),
],
));
};
#!/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']);
});
#!/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.
$ bin/phpss start
Learn how to integrate your Symfony application with the Monolog logger.
Read more...