rich-id/autoconfigure-bundle
Rich ID Autoconfigure Bundle simplifies Symfony service configuration by applying convention-based defaults, reducing boilerplate and keeping dependency injection setup clean and maintainable. Suitable for PHP projects that want faster autoconfiguration with minimal manual wiring.
Install the package via Composer (composer require vendor/package), then register its service provider (if not auto‑discovered). Publish any configuration file with php artisan vendor:publish and review the services scan paths.
The first place to look is the attribute classes: #[Service], #[Tag], and the new #[MethodCall]. A minimal use case:
#[Service]
#[Tag('reports')]
#[MethodCall('setLogger', args: [Logger::class])]
class SalesReport { ... }
Then inject all tagged services using Laravel’s tagged binding or the package’s own injection attribute:
public function __construct(#[Tagged('reports')] iterable $reports) { ... }
After defining your first service, run php artisan optimize:clear to ensure annotations are re‑scanned. The package fits naturally into Laravel’s container – start by converting one existing singleton or bind to an annotated service to see the registration and tagging in action.
#[Tag('name')] to group related services (e.g., payment.gateway, formatter). Inject them as iterable or resolve via app()->tagged('name'). This is ideal for strategy patterns, event listeners, or plugin systems.#[MethodCall] annotation lets you call setters or configuration methods on the service right after it is built. Example: #[MethodCall('setConfig', args: ['key' => 'value'])]. Method calls execute in the order they are declared, so you can chain dependencies.app/Services). The package scans that path and registers each class automatically. Combine with interfaces: tag implementations of an interface, then inject the tagged collection.#[Tag] or #[MethodCall], clear the container/annotation cache (php artisan optimize:clear). In production, ensure the scan cache is warmed during deployment.#[MethodCall] annotations execute in the order they appear on the class. If a method depends on another, declare them sequentially. You cannot reference the result of a previous call directly – use a single method that orchestrates the logic instead.#[Tag] explicitly to each concrete class you want in the collection.php artisan tinker and app()->tagged('your-tag') to inspect resolved instances. If a service is missing, check that its class is within the configured scan paths and that the #[Service] attribute is present.config/services.php (or similar). Ensure the service provider is registered before other providers that depend on tagged services.ServiceDefinition event. Check the package’s source for ServiceDefinition or Attribute classes to add your own logic. For method calls, the args array accepts both positional and named arguments – use named arguments for clarity when a method has many optional parameters.How can I help you explore Laravel packages today?