symfony/framework-bundle
FrameworkBundle integrates Symfony components into the full-stack Symfony framework, providing core wiring for services, configuration, routing, controllers, and more. Part of the main Symfony repository; see docs for contributing, issues, and PRs.
symfony/framework-bundle is the foundational glue between Symfony components (e.g., HTTP Kernel, Dependency Injection, Console, Validation) and the full-stack Symfony framework. It is mandatory for any Laravel-like application targeting Symfony’s ecosystem, as it provides:
config/packages/*, while Laravel uses config/app.php and service providers.[Route] attributes (like Laravel’s Route::get() but type-safe).EventDispatcher is more granular than Laravel’s Events facade.Illuminate\Foundation\Application with Symfony’s Kernel).KernelTestCase for HTTP tests).Facade pattern clashes with Symfony’s PSR-11 container.config/packages/ is verbose vs. Laravel’s config/.middleware key in config/packages/framework.yaml differs from Laravel’s Kernel.php.symfony/twig-bundle.doctrine/orm-bundle.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Container Conflicts | High | Use symfony/dependency-injection to resolve Laravel’s Illuminate\Container. |
| Routing Duplication | Medium | Map Laravel routes to Symfony’s YamlConfigLoader or attribute routes. |
| Event System | Medium | Bridge Laravel’s Events to Symfony’s EventDispatcher via a listener. |
| Configuration Merge | High | Use Symfony’s Extension system to override Laravel’s config/. |
| Testing Overlap | Low | Prefer Symfony’s KernelTestCase for HTTP tests; keep Laravel’s HttpTests for legacy. |
| Middleware Order | High | Explicitly define middleware in config/packages/framework.yaml. |
| Service Provider → Extension | High | Convert Laravel providers to Symfony Extension classes. |
symfony/framework-bundle as the sole container.Laravel\Container as a Symfony service).symfony/twig-bridge or a custom Blade compiler.doctrine/orm-bundle and entity mapping adjustments.cache:warmup replaces Laravel’s config:cache.phpunit.xml configs (Symfony’s KernelTestCase vs. Laravel’s TestCase).Middleware interface.[Autowire] or register in services.yaml.Extension to abstract Laravel-like config files.| Component | Symfony Bundle Equivalent | Integration Notes |
|---|---|---|
| Laravel Container | symfony/dependency-injection |
Use FrameworkBundle’s autowiring. |
| Laravel Routing | symfony/http-kernel + routing |
Map Route::get() to [Route] attributes. |
| Laravel Middleware | framework.yaml middleware stack |
Convert app/Http/Kernel.php to config. |
| Laravel Service Providers | Extension classes |
Extend AbstractExtension for config. |
| Laravel Events | symfony/event-dispatcher |
Bridge via a listener service. |
| Laravel Blade | symfony/twig-bundle |
Use TwigBridge or custom compiler. |
| Laravel Eloquent | doctrine/orm-bundle |
Requires entity mapping adjustments. |
| Laravel Queues | symfony/messenger |
Replace Queue workers with Messenger. |
| Laravel Artisan | symfony/console |
Use Command classes with FrameworkBundle. |
ServiceProvider with Symfony Extension.bind()/singleton() to services.yaml or autowiring.// Laravel (old)
$this->app->singleton(MyService::class, function () {
return new MyService();
});
// Symfony (new)
// services.yaml
My\Service\MyService: ~
Route::get() with [Route] attributes or YAML routes.RouteServiceProvider to Symfony’s routing config.// Laravel (old)
Route::get('/hello', [Controller::class, 'hello']);
// Symfony (new)
#[Route('/hello', name: 'hello')]
public function hello(): Response { ... }
app/Http/Kernel.php to config/packages/framework.yaml.# framework.yaml
middleware: ['framework.http_cache', 'framework.trusted_proxies']
phpunit.xml with Symfony’s KernelTestCase.class MyTest extends KernelTestCase {
public function testHomepage() {
$client = static::createClient();
$client->request('GET', '/');
$this->assertResponseStatusCodeSame(200);
}
}
symfony/twig-bundle).KernelTestCase is superior to Laravel’s for HTTP scenarios.config/packages/ is more explicit than Laravel’s config/.symfony/console instead of Artisan for CLI tasks.How can I help you explore Laravel packages today?