Symfony Runtime
Decouples PHP applications from global state and framework bootstrapping conventions
Repository Health
Technical Analysis
Symfony Runtime is the small abstraction layer that decides how a PHP application actually gets executed — reading $_SERVER, wiring up error handlers, loading .env files, and dispatching to the right runner for CLI commands, HTTP kernels, or FrankenPHP workers. Instead of every entry-point script (public/index.php, bin/console) hard-coding bootstrap logic and reaching into superglobals, an application exposes a single callable that returns an app object, and Runtime figures out the rest.
Because the bootstrapping contract is just “return a callable, get back a RunnerInterface,” any PHP project — not only full Symfony applications — can adopt it via the generic GenericRuntime implementation, while SymfonyRuntime adds awareness of symfony/console, symfony/http-foundation, symfony/http-kernel, and symfony/dotenv when those components are present. This makes applications easier to test (no global state to fake) and portable across execution environments, including long-running FrankenPHP worker processes.
What You Get
- A
GenericRuntimethat works with plain PHP callables returningarray $context,array $argv, orarray $request, with zero framework dependency - A
SymfonyRuntimethat auto-detects installed Symfony components (console, http-foundation, http-kernel, dotenv) and injects the right argument types - Automatic
.envfile loading viasymfony/dotenvintegration, including override and extra-path support - Built-in
FrankenPhpWorkerRunnersupport for long-running worker processes, including configurable request-count restarts and kernel reset - A Composer plugin that wires the generated
autoload_runtime.phpentry point automatically on install
Common Use Cases
- Bootstrapping a Symfony application’s
public/index.phpandbin/consolewithout repeating environment/error-handler setup - Writing framework-agnostic PHP scripts that still get
.envloading, debug-aware error handling, and typed argument injection - Running Symfony HTTP kernels or console applications inside FrankenPHP worker mode for persistent, low-latency request handling
- Testing application logic in isolation by injecting fake runtimes/resolvers instead of relying on global PHP state
Under The Hood
Architecture - The design centers on two cooperating interfaces: ResolverInterface, which reflects on the app callable’s parameters and resolves matching arguments, and RunnerInterface, which decides how to actually execute the resolved app (as a closure return, an HTTP response, a console command, or a FrankenPHP worker loop). GenericRuntime implements the base contract using only PHP superglobals and reflection; SymfonyRuntime extends it, adding a resolveType() override that recognizes Request, Application, Command, and InputInterface/OutputInterface types when the corresponding Symfony components (http-foundation, console) are installed, and getRunner() dispatches to HttpKernelRunner, ConsoleApplicationRunner, ResponseRunner, or FrankenPhpWorkerRunner in Runner/ based on what the app callable returns. A Composer plugin (Internal/ComposerPlugin.php) generates Internal/autoload_runtime.template into the vendor autoload files at install time, wiring the callable convention into public/index.php/bin/console automatically.
Tech Stack - Pure PHP 8.4+ with no runtime dependencies beyond composer-plugin-api; all Symfony component integrations (symfony/console, symfony/http-foundation, symfony/http-kernel, symfony/dotenv, symfony/dependency-injection) are optional require-dev/soft dependencies detected via class_exists() checks, so the same package works standalone or fully wired into a Symfony app. Tests run on PHPUnit with phpunit.xml.dist configuring the suite.
Code Quality - The codebase is compact (roughly a dozen source files) with PSR-4 autoloading split between Symfony\Component\Runtime\ and an internal Symfony\Runtime\Symfony\Component\ namespace for polyfill-style internals. Tests/SymfonyRuntimeTest.php covers FrankenPHP worker detection edge cases (truthy/falsy env values), custom type resolution overrides, untyped-argument error messages, and loop-max validation with explicit LogicException assertions — indicating deliberate attention to edge cases around environment-variable parsing and error messaging rather than just happy-path coverage. Strict typing (readonly properties, typed constructor arrays with PHPDoc shape annotations) is used throughout.
API Design - The public surface is deliberately minimal: applications interact with Runtime only by returning a callable from their entry point, with argument types resolved via reflection rather than explicit configuration. This keeps boilerplate near zero for simple scripts while still supporting rich typed injection (Request, Command, InputInterface) for full Symfony apps, and the RuntimeInterface/ResolverInterface/RunnerInterface split gives extension points for custom runtimes without needing to fork the base classes.
Used by 4 apps in this directory
BillaBear
Ecommerce · Invoicing Finance
Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.
Hyvor Relay
Devops · AI Development · Monitoring
Self-hosted, open-source email API that automates DNS, manages SMTP delivery, and provides deep observability — replacing SES, Mailgun, and SendGrid with infrastructure you fully own.
Kimai
Invoicing Finance · Project Management
Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.