- Can I use this package directly in a Laravel project without Symfony?
- No, this package is designed for Symfony and relies on its Dependency Injection system and MakerBundle. For Laravel, you’d need to either wrap Symfony’s DI in Laravel’s container or reimplement the registry logic using Laravel’s `bindTagged()` method. A hybrid approach (e.g., Symfony microservices + Laravel frontend) is also possible.
- What Laravel versions support this package if I adapt it?
- Laravel 8.40+ is required for full PHP 8 attribute support (needed for Symfony’s `#[TaggedIterator]`). Older versions would need annotation workarounds or manual tagging via `bindTagged()`, which adds complexity. Test thoroughly if using Laravel < 8.40.
- How do I install this in a Symfony project?
- Run `composer require alsciende/make-registry-bundle`, enable the bundle in `bundles.php`, and use the `make:registry` command (e.g., `php bin/console make:registry OutputFormatter`). No additional configuration is needed for basic usage—it auto-generates interfaces, sample services, and a registry class.
- What’s the difference between this and Laravel’s `bindTagged()`?
- This package automates registry scaffolding (interface, sample service, and registry class) via a CLI command, while `bindTagged()` requires manual setup. It also enforces stricter typing and duplicate service checks. For Laravel, you’d lose the convenience but gain native compatibility.
- Will this work with API Platform or Lumen?
- Yes, if using Symfony components (e.g., MakerBundle). Lumen’s lightweight DI can host Symfony’s registry logic, but full integration requires wrapping Symfony’s container or using a facade. API Platform projects benefit directly from Symfony’s native support.
- How do I handle PHP 8 attributes in Laravel < 8.40?
- Use a polyfill like `ramsey/uuid`’s attribute package or fall back to annotations (e.g., `@AutoconfigureTag`). However, this adds complexity and may not fully replicate Symfony’s attribute-based tagging. Test edge cases like service overrides or dynamic tags.
- Are there alternatives for Laravel-only registry patterns?
- Yes, consider `spatie/laravel-registry` for Laravel-native solutions or manually implement registries with `bindTagged()` and service providers. This package is only worth adapting if you’re already using Symfony components or need rapid scaffolding for complex registries.
- How do I integrate this with Laravel’s Artisan?
- Create a custom Artisan command to proxy Symfony’s `make:registry` or use Symfony’s CLI in CI/CD pipelines. For example, add a `php artisan make:registry` command that calls `symfony/console` internally. Ensure your Laravel container can resolve Symfony’s DI services.
- Does this package support dynamic service registration at runtime?
- No, this package relies on Symfony’s compiler passes to resolve tagged services at container build time. For dynamic registration, you’d need to extend the generated `Registry` class with runtime methods (e.g., `addService()`) and manually manage the `$services` array.
- How will Symfony 6.4+ updates affect this package?
- Future Symfony updates (e.g., MakerBundle v2) may introduce breaking changes, especially around attributes or DI behavior. Monitor the package’s changelog and test upgrades early. If using a hybrid Laravel setup, ensure your custom wrappers or facades remain compatible with Symfony’s evolving API.