Symfony bundle for PHPStreamServer

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 0

Type:symfony-bundle

v0.6.0 2025-07-05 14:36 UTC

This package is auto-updated.

Last update: 2025-07-05 14:42:42 UTC


README

PHPStreamServer logo

Symfony Bundle for PHPStreamServer

PHP >=8.2 Version Downloads

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...