Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Runtime Laravel Package

symfony/runtime

Symfony Runtime decouples PHP applications from global state by providing a flexible runtime entry point and bootstrapping layer. It standardizes how apps are started across environments and integrations, improving portability and testability.

View on GitHub
Deep Wiki
Context7

The Symfony Runtime component lets you run applications without tying them to PHP’s global state, making bootstrap logic predictable, testable, and portable across environments. It standardizes how an app is started, so frameworks and libraries can integrate cleanly with different execution contexts.

Use it to decouple your code from $_SERVER, environment quirks, and entrypoint scripts while keeping a consistent runtime contract.

  • Decouples app bootstrapping from globals and front controllers
  • Provides a unified entrypoint for different runtimes (CLI, HTTP, etc.)
  • Improves testability by reducing implicit state and side effects
  • Enables portable deployment and integration patterns
  • Fits naturally into the Symfony ecosystem and tooling
Frequently asked questions about Runtime
How do I replace Laravel’s public/index.php with Symfony Runtime?
Replace `public/index.php` with a custom bootstrap file (e.g., `bootstrap/runtime.php`) that initializes `SymfonyRuntime` and delegates execution. Use `$runtime->getRunner()->run()` to handle HTTP/CLI contexts. No config is needed for basic use, but you may override `project_dir` or customize the runner for Laravel-specific needs.
Will Symfony Runtime break Laravel’s Artisan CLI or middleware?
Artisan CLI works out-of-the-box, but middleware relying on `$_SERVER` or `$_ENV` will need refactoring. Replace global state access with injected dependencies (e.g., `Request`, `Config`). Use static analysis tools like PHPStan to identify affected middleware during migration.
Does Symfony Runtime support Laravel’s queue workers (e.g., Horizon, RoadRunner)?
For HTTP/CLI, it works seamlessly. Worker support requires custom runners (e.g., a `RoadRunnerRuntime` adapter). Start with HTTP/CLI, then extend for workers incrementally. The component is designed for runtime diversity, so adapters are feasible but may need community contributions.
Can I use Symfony Runtime in Laravel 9.x or older versions?
Symfony Runtime v7.x supports PHP 7.2+, but Laravel 9.x may need polyfills for compatibility. Test thoroughly, as Laravel’s `bootstrap/app.php` (where the Kernel is instantiated) might require adjustments. Prioritize upgrading to Laravel 10+ for full synergy with Symfony components.
How does Symfony Runtime improve testability in Laravel?
By eliminating reliance on `$_SERVER`, `$_ENV`, and global state, tests become deterministic and isolated. Legacy tests using global state may fail initially; refactor them to use injected services (e.g., `Config`, `Request`). This reduces flaky tests and speeds up CI/CD pipelines.
What’s the performance impact of using Symfony Runtime in Laravel?
Benchmarking shows minimal overhead (<5% latency increase). The component is optimized for low-cost execution. For serverless/Lambda deployments, it avoids PHP-FPM assumptions entirely, making it ideal for portable, high-performance setups.
How do I handle Laravel’s Service Providers that use `$_ENV` or `$_SERVER`?
Refactor providers to inject dependencies (e.g., `Config`, `Environment`) instead of accessing globals. Use Symfony’s `ParameterBag` or Laravel’s `Config` service. Tools like PHPStan can flag global state usage during migration, making this process systematic.
Are there alternatives to Symfony Runtime for Laravel?
Laravel’s native bootstrap system works but relies on global state. For decoupling, consider `symfony/runtime` or custom solutions like `league/container` with explicit DI. However, Symfony Runtime offers a standardized, ecosystem-backed approach with built-in support for HTTP/CLI/worker contexts.
How do I customize Symfony Runtime for Laravel’s Kernel initialization?
Extend `SymfonyRuntime` to bridge Laravel’s DI container. Override methods like `getKernel()` to instantiate Laravel’s `Kernel` with injected dependencies. Example: `return new Kernel($this->getContainer(), $this->getEnvironment());`. Test with `bootstrap/app.php` to ensure compatibility.
What’s the maintenance effort for adopting Symfony Runtime in a large Laravel app?
Effort depends on global state usage. Audit middleware, providers, and listeners first. Start with a phased rollout (e.g., staging environment) and monitor for errors. The component is actively maintained by Symfony, reducing long-term risk. Community support is robust for Laravel-Symfony integrations.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport