Symfony intergation
This bundle provides integration of PHPStreamServer with the Symfony framework.
Installation
$ composer require phpstreamserver/symfony
Configuration
Enable the bundle
config/bundles.php
<?php
return [
// ...
PHPStreamServer\Symfony\PHPStreamServerBundle::class => ['all' => true],
];
Create phpss.config.php file in the config directory
config/phpss.config.php
<?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(),
],
));
};
You can register additional plugins and workers in this file.
This bundle adds new Symfony-specific workers:
Create phpss file in the bin directory
bin/phpss
#!/usr/bin/env php
<?php
use App\Kernel;
use PHPStreamServer\Symfony\PHPStreamServerRuntime;
$_SERVER['APP_RUNTIME'] = PHPStreamServerRuntime::class;
require_once \dirname(__DIR__).'/vendor/autoload_runtime.php';
return static function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
Start the server
$ bin/phpss start
This bundle adds new Symfony-specific options to the start command: --env
, --no-debug
. For more details, refer to the help output.
Resolvable arguments in phpss.config.php
The closure returned from the phpss.config.php may have zero or more arguments:
return static function (Server $server): void {
// ...
};
The following arguments are supported:
🔵 Server $server
Server instance to register plugins and workers
🔵 array $context
This is the same as $_SERVER + $_ENV
🔵 string $projectDir
Project root directory
🔵 string $env
Current environment