mmoreram/symfony-bundle-dependencies
Symfony bundle to manage inter-bundle dependencies and load order. Define requirements between bundles and let the resolver ensure needed bundles are enabled and initialized first, helping avoid missing services and configuration issues in complex apps.
Symfony Bundle Dependency Management: The package is explicitly designed for Symfony bundles, enabling explicit declaration of inter-bundle dependencies (e.g., requires, conflicts). This aligns well with Laravel if:
illuminate/contracts or custom packages).Alternative Use Cases:
composer.json (though Laravel lacks native bundle-level constraints).DependencyGraph) to validate package compatibility in CI/CD.Bundle class and Extension interfaces.symfony/http-kernel-bridge or custom adapters).DependencyGraph: Parse and validate dependencies (could be adapted for Laravel’s config() or ServiceProvider relationships).BundleInterface: Replace with Laravel’s Illuminate\Support\ServiceProvider or a custom interface.ContainerBuilder).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony-Specific APIs | High | Create adapters (e.g., LaravelBundle wrapper). |
| Laravel’s Loose Coupling | Medium | Use dependency graph logic without Bundle class. |
| Outdated Maintenance | Low | Fork or patch for critical fixes. |
| Composer Autoloading | Low | Ensure composer.json constraints are met. |
Why Symfony?
config() or ServiceProvider::boot() instead?Scope of Adoption
composer.json constraints, or supplement them?php-dependency-graph) already solving this?Long-Term Viability
Performance Impact
| Component | Laravel Fit | Integration Strategy |
|---|---|---|
Symfony Bundle |
❌ No | Replace with ServiceProvider or custom trait. |
DependencyGraph |
✅ Partial | Extract logic for Laravel’s composer.json analysis. |
Extension Interface |
❌ No | Use Laravel’s Configurable or DeferrableServiceProvider. |
| Console Commands | ✅ Yes | Wrap in Laravel’s Artisan commands. |
Symfony/Lumen Projects:
// config/bundles.php
return [
new \App\Bundle\MyBundle(),
new \Vendor\SymfonyBundle(),
];
Laravel Projects:
DependencyGraph class and adapt it to parse Laravel’s config() or ServiceProvider relationships.$graph = new CustomDependencyGraph();
$graph->addNode('auth', ['providers' => ['UserProvider']]);
$graph->validate();
LaravelBundle trait to bridge BundleInterface to ServiceProvider.class MyBundle implements \Symfony\Component\HttpKernel\Bundle\Bundle
{
use \Mmoreram\LaravelBundleTrait;
}
Hybrid Approach:
composer.json constraints without runtime overhead.Container and Config components (v4+).
composer require symfony/http-kernel-bridge if missing.FrameworkBundle).bootstrap/app.php and config/app.php.Phase 1: Proof of Concept
DependencyGraph for Laravel’s dependency structure.Phase 2: Integration
bootstrap/app.php or a custom ServiceProvider.Phase 3: CI/CD Enforcement
.github/workflows/validate-deps.yml:
- run: php vendor/bin/validate-bundle-deps
composer why + composer why-not for ad-hoc checks.| Scenario | Impact | Mitigation |
|---|---|---|
| Symfony API Breaking Change | High (if using core classes) | Fork or switch to alternatives. |
| Laravel-Symfony Mismatch | Medium (integration errors) | Isolate behind adapters. |
| Outdated Package | Low (MIT license allows forks) | Patch or replace with modern tools. |
| Overly Strict Validation | Medium (false positives) | Configure allowed conflicts. |
Bundle system).phpstan/extension-installer to auto-load the package in dev environments.make:bundle Artisan command for Laravel projects.How can I help you explore Laravel packages today?