rgzone/folk-bundle

Symfony bundle for integration with the PHP Folk extension.

Maintainers

Package info

bitbucket.org/stelzek/symfony-folk-bundle

Type:symfony-bundle

pkg:composer/rgzone/folk-bundle

Statistics

Installs: 3

Dependents: 1

Suggesters: 0

dev-master 2026-06-06 00:54 UTC

This package is auto-updated.

Last update: 2026-06-06 00:54:44 UTC


README

rgzone/folk-bundle is a Symfony bundle for integration with the PHP Folk extension.

The current direction is inspired by Folk-Project/folk-symfony, but this bundle is being developed as a dedicated Symfony bundle with a focus on runtime integration.

Repository: https://bitbucket.org/stelzek/symfony-folk-bundle

Folk SDK: https://github.com/Folk-Project/folk-sdk

Requirements

  • PHP >= 8.4
  • Symfony ^8.0
  • PHP extension ext-folk
  • folk/sdk:^0.2.6

The PHP version floor is intentionally set to 8.4+, which also excludes older Symfony generations from the supported matrix.

Installation

Once the public API stabilizes, installation is expected to look like this:

composer require rgzone/folk-bundle

This bundle builds on folk/sdk: https://github.com/Folk-Project/folk-sdk

Worker binary:

vendor/bin/folk-worker

TOML worker command example:

[worker]
command = ["vendor/bin/folk-worker"]

Handler Services

WorkerLoop consumes handlers by interface id.

Default bundle bindings:

  • Folk\Sdk\Http\HttpModeHandler -> RGZ\FolkBundle\Handler\Http\FolkHttpHandler
  • Folk\Sdk\Grpc\GrpcModeHandler -> Folk\Sdk\Grpc\GrpcRouter

The bundle does not register a default binding for:

  • Folk\Sdk\Jobs\JobsModeHandler

Jobs are application-defined only.

Examples for config/services.yaml:

HTTP override:

services:
  App\Folk\Http\AppHttpHandler:
    autowire: true

  Folk\Sdk\Http\HttpModeHandler: '@App\Folk\Http\AppHttpHandler'

gRPC router override:

services:
  App\Folk\Grpc\AppGrpcRouter:
    class: Folk\Sdk\Grpc\GrpcRouter

  Folk\Sdk\Grpc\GrpcModeHandler: '@App\Folk\Grpc\AppGrpcRouter'

gRPC service registration inside the router:

services:
  App\Grpc\GreeterService:
    tags:
      - { name: 'folk.grpc', service: 'helloworld.Greeter' }

The tagged service itself is passed to GrpcRouter::register() as the handler object.

Jobs binding:

services:
  App\Folk\Jobs\AppJobsHandler:
    autowire: true

  Folk\Sdk\Jobs\JobsModeHandler: '@App\Folk\Jobs\AppJobsHandler'

If you need direct access to a concrete class, register that concrete service under its own id and alias the interface to it.

Reset Between Requests

The bundle bridges Symfony service resetting into the Folk worker loop.

If your services implement Symfony's reset contract, they are reset between loop iterations through services_resetter:

use Symfony\Contracts\Service\ResetInterface;

final class SomeStatefulService implements ResetInterface
{
    public function reset(): void
    {
        // clear per-request state here
    }
}

For bundle-specific reset hooks, implement Folk\Sdk\Reset\ResettableInterface. Such services are auto-tagged and registered in the worker loop automatically:

use Folk\Sdk\Reset\ResettableInterface;

final class SomeFolkResetter implements ResettableInterface
{
    public function reset(): void
    {
        // clear loop-local state here
    }
}

Use this for state that must survive service construction but must not leak from one handled request or job to the next.

Autoload namespace: RGZ\FolkBundle\

License

MIT