crazy-goat/workerman-bundle
Symfony bundle integrating Workerman to run a high-performance async HTTP server, scheduler and supervisor in pure PHP. Keeps the Symfony kernel/container alive between requests for faster apps. Supports SO_REUSEPORT and optional direct Request creation for speed.
WorkermanBundle supports packaging your entire Symfony application into a single-file PHAR archive or a standalone binary for simplified deployment.
# Build a PHAR archive (requires PHP on target system)
php bin/console workerman:build:phar
# Run from the PHAR
php app.phar workerman:server start -d
php app.phar cache:clear
php app.phar doctrine:migrations:migrate
# Build a self-contained binary (no PHP required on target)
php bin/console workerman:build:bin
# Run from the binary
./app.bin workerman:server start -d
# config/packages/workerman.yaml
workerman:
# Writable runtime directory (defaults to project_dir)
# In PHAR mode, automatically set to directory containing the PHAR
runtime_dir: '%kernel.project_dir%'
build:
# Output directory for built artifacts
build_dir: '%kernel.project_dir%/build'
# Your Symfony Kernel class
kernel_class: 'App\\Kernel'
# Output file names
phar_filename: 'app.phar'
bin_filename: 'app.bin'
# PHP version for phpmicro.sfx (default: current version)
bin_php_version: 8.3
# PHPMicro SFX source (priority: sfx-file CLI > sfx.file > sfx-url > sfx.url > default)
sfx:
url: null # Custom download URL
file: null # Local path to phpmicro.sfx
sha256: null # SHA-256 hex digest for checksum verification (strongly recommended)
allow_insecure: false # Disable TLS peer verification (off by default; use only for local mirrors)
# Files excluded from the PHAR
exclude_patterns:
- '/\.git/'
- '/tests/'
- '/var/'
exclude_files:
- '.env'
- '.env.local'
# Custom php.ini directives for the standalone binary (BIN mode only)
custom_ini: |
opcache.enable=1
opcache.enable_cli=1
opcache.jit=1255
memory_limit=256M
build.sfx.sha256The SHA-256 hex digest of the expected phpmicro.sfx binary. When configured, the SFX binary
is verified against this checksum after download (and after zip extraction, if applicable),
protecting against supply-chain attacks (corrupted download, man-in-the-middle substitution).
Required for all builds unless --unsafe-no-checksum is explicitly passed.
The --sfx-checksum CLI option overrides this config value when provided.
# Obtain the checksum for a specific PHP version
curl -sL "https://download.workerman.net/php/php8.3.micro.sfx" | sha256sum
# After obtaining a trusted copy, use its checksum in a subsequent build:
php bin/console workerman:build:bin --sfx-checksum="$(sha256sum /path/to/trusted.sfx | cut -d' ' -f1)"
Cross-reference: src/DependencyInjection/ConfigurationTreeBuilder.php:306-309.
--unsafe-no-checksumBypasses the mandatory checksum requirement and allows the download without SHA-256 verification. Use only when:
Without this flag, the build fails with an error when no --sfx-checksum or build.sfx.sha256
is configured.
# Warning: skips checksum verification
php bin/console workerman:build:bin --unsafe-no-checksum
build.sfx.allow_insecureDisables TLS peer verification (verify_peer, verify_peer_name) when downloading the SFX
binary. Off by default — keep it off unless you are serving phpmicro.sfx from a local
mirror with a self-signed certificate.
The --insecure CLI flag enables the same behavior.
Security implications when enabled:
build.sfx.sha256 to verify the binary after downloadCross-reference: src/DependencyInjection/ConfigurationTreeBuilder.php:310-313.
The build command creates a PHAR archive containing your entire Symfony application (source, vendor, config). The embedded stub:
APP_CACHE_DIR and APP_LOG_DIR to writable pathsvar/cache, var/log, var/run directories.env from outside the PHAR (if present)Builds on top of PHAR mode by concatenating:
[phpmicro.sfx] + [optional custom_ini header] + [app.phar]
The phpmicro.sfx is a static PHP interpreter. It's downloaded automatically from https://download.workerman.net/php/php{VERSION}.micro.sfx, or you can provide a local file via --sfx-file option.
In PHAR/BIN mode, all writable paths (cache, logs, PID files) are redirected outside the archive to the runtime directory:
| Path | Normal Mode | PHAR/BIN Mode |
|---|---|---|
| Cache | {project}/var/cache/ |
{runtimeDir}/var/cache/ |
| Logs | {project}/var/log/ |
{runtimeDir}/var/log/ |
| PID file | {project}/var/run/ |
{runtimeDir}/var/run/ |
The runtime directory defaults to the directory containing the PHAR/BIN file, and can be overridden with WORKERMAN_RUNTIME_DIR env var.
.env file must be external — place it next to the PHAR/BIN filephar.readonly=0 in php.ini during buildworkerman:build:pharphp bin/console workerman:build:phar [options]
Options:
-o, --output-dir=DIR Output directory (default: config build.build_dir)
--filename=NAME Output filename (default: config build.phar_filename)
workerman:build:binphp bin/console workerman:build:bin [options]
Options:
-o, --output-dir=DIR Output directory
--filename=NAME Output filename (default: config build.bin_filename)
--sfx-file=PATH Local path to phpmicro.sfx
--sfx-url=URL URL to download phpmicro.sfx
--sfx-checksum=HASH Expected SHA-256 hex digest (mandatory unless --unsafe-no-checksum)
--php-version=VER PHP version for static binary (e.g., 8.3)
--insecure Disable TLS peer verification (not recommended)
--unsafe-no-checksum Skip SHA-256 verification (not recommended)
How can I help you explore Laravel packages today?