{"id":15077666,"url":"https://github.com/highcoreorg/registry-bundle","last_synced_at":"2026-02-21T01:01:40.698Z","repository":{"id":225644654,"uuid":"766506549","full_name":"highcoreorg/registry-bundle","owner":"highcoreorg","description":"Symfony bundle for https://github.com/highcoreorg/regitry","archived":false,"fork":false,"pushed_at":"2024-09-17T15:46:15.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T10:49:00.080Z","etag":null,"topics":["registry","registry-pattern","symfony-bundle","symfony-registry"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/highcoreorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-03T13:09:59.000Z","updated_at":"2024-09-17T15:46:19.000Z","dependencies_parsed_at":"2024-07-08T23:36:07.425Z","dependency_job_id":"86cc2db3-a798-475f-b3d7-984fe9e5e8f0","html_url":"https://github.com/highcoreorg/registry-bundle","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"c05a109f0aee59ae860f65e35c31cea9496a20c9"},"previous_names":["highcoreorg/registry-bundle"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/highcoreorg/registry-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/highcoreorg%2Fregistry-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/highcoreorg%2Fregistry-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/highcoreorg%2Fregistry-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/highcoreorg%2Fregistry-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/highcoreorg","download_url":"https://codeload.github.com/highcoreorg/registry-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/highcoreorg%2Fregistry-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29669856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"ssl_error","status_checked_at":"2026-02-20T23:52:33.807Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["registry","registry-pattern","symfony-bundle","symfony-registry"],"created_at":"2024-09-25T04:06:21.987Z","updated_at":"2026-02-21T01:01:40.671Z","avatar_url":"https://github.com/highcoreorg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony Registry Bundle\n\n**RegistryBundle** is a Symfony bundle that provides a convenient mechanism for working with registries. \nThis package allows you to automatically register services with specific attributes and interfaces in registries.\n\n## Installation\nTo install this package, use Composer:\n```bash\ncomposer require highcore/registry-bundle\n```\n\n## Configuration\nAfter installation, add RegistryBundle to your Symfony configuration file (config/bundles.php):\n```php\nreturn [\n    // ...\n    Highcore\\Bundle\\RegistryBundle\\RegistryBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n## Usage\n### Registering Registries\nRegistries are registered in the bundle class using a Compiler Pass. This allows services marked with attributes to be automatically registered in the appropriate registries during the container compilation phase.\n\nExample of Registering a Registry\n```php\n\u003c?php\ndeclare(strict_types=1)\n\nnamespace App\\YourBundle;\n\nuse Symfony\\Component\\DependencyInjection\\ContainerBuilder;\nuse Symfony\\Component\\HttpKernel\\Bundle\\Bundle;\nuse Highcore\\Bundle\\RegistryBundle\\Compiler\\Pass\\ServiceAttributeRegistryPass;\nuse Highcore\\Component\\Criteria\\Doctrine\\Handler\\CriteriaRepository;\nuse Highcore\\Bundle\\RegistryBundle\\Registry\\IdentityServiceRegistry;\nuse Highcore\\Bundle\\RegistryBundle\\Registry\\ServiceRegistry;\n\nclass YourBundle extends Bundle\n{\n    public function build(ContainerBuilder $container): void\n    {\n        parent::build($container);\n\n        $container-\u003eaddCompilerPass(new ServiceAttributeRegistryPass(\n            definitionId: 'some.your.project.namespace.first.resource.registry',\n            definitionClass: IdentityServiceRegistry::class,\n            targetClassAttribute: \\App\\YourBundle\\Attribute\\AsYourResourceAttribute::class, // your attribute class\n            interface: \\App\\YourBundle\\YourServiceInterface::class, // your interface class (interface is optional, if passed, CompilerPass will check your service for an implementation of that interface)\n        ));\n\n        $container-\u003eaddCompilerPass(new ServiceAttributeRegistryPass(\n            definitionId: 'some.your.project.namespace.second.resource.registry',\n            definitionClass: ServiceRegistry::class,\n            targetClassAttribute: \\App\\YourBundle\\Attribute\\AsYourSecondResourceAttribute::class,\n            // register registry without interface\n        ));\n    }\n}\n```\n\nIn this example, two registries are registered using CompilerPass:\n### Registry for your first resource: \nRegisters all services marked with the \\App\\AsYourResourceAttribute attribute, and each service must implement the \\App\\YourServiceInterface interface.\n1. **Example Interface for your first registry:**\n```php\n\u003c?php\ndeclare(strict_types=1)\n\nnamespace App\\YourBundle;\n\ninterface YourServiceInterface\n{\n    public function yourMethod(): void;\n}\n```\n2. **Example Attribute for your first registry:**\n```php\n\u003c?php\ndeclare(strict_types=1)\n\nnamespace App\\YourBundle\\Attribute;\n\nuse Doctrine\\Common\\Annotations\\Annotation\\NamedArgumentConstructor;\n\n#[\\Attribute(\\Attribute::TARGET_CLASS)]\n#[NamedArgumentConstructor]\nclass AsYourResourceAttribute implements IdentityServiceAttributeInterface\n{\n    public function __construct(private readonly ?string $identifier = null)\n    {\n    }\n\n    // If self::hasIdentifier() returns false, this method will not be called,\n    // instead we will take the name of the class to which this attribute will be assigned as the identifier\n    public function getIdentifier(): string\n    {\n        return $this-\u003eidentifier;\n    }\n\n    public function hasIdentifier(): bool\n    {\n        return null !== $this-\u003eidentifier;\n    }\n}\n```\n\n### Registry for your second resource\nRegisters all services marked with the \\App\\AsYourSecondResourceAttribute attribute.\n\n**For example, for second registry we will create only attribute**\n```php\n\u003c?php\ndeclare(strict_types=1)\n\nnamespace App;\n\nuse Highcore\\Component\\Registry\\Attribute\\ServiceAttributeInterface;\n\n#[\\Attribute(\\Attribute::TARGET_CLASS)]\nclass AsYourSecondResourceAttribute implements ServiceAttributeInterface\n{\n}\n```\n\n## Registering your service in the registry\nServices can be automatically added to the registry using attributes. \nSimply add attributes to the service classes you want to register and register them in the symfony service container:\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nnamespace App\\YourBundle\\Service;\n\nuse Highcore\\JsonApi\\Configurator\\JsonApiResourceConfigurator;\nuse App\\YourBundle\\Attribute\\AsYourResourceAttribute;\nuse App\\YourBundle\\YourServiceInterface;\n\n#[AsYourResourceAttribute('some_identifier')]\nclass MyService implements YourServiceInterface\n{\n    public function yourMethod(): void\n    {\n        // Implementation of the configurator\n    }\n}\n```\n\nRegister your service in the symfony container:\n```php\n# src/YourBundle/Resources/config/services.php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ContainerConfigurator;\n\nreturn static function (ContainerConfigurator $configurator): void {\n    $services = $configurator-\u003eservices();\n    $defaults = $services-\u003edefaults();\n    $defaults-\u003eautowire();\n    $defaults-\u003eautoconfigure();\n\n    // that's all you need to register your service in the registry\n    $services-\u003eset(\\App\\YourBundle\\Service\\MyService::class);\n};\n```\n\n## Using the registry\nTo get started, register your service and pass registry \"some.your.project.namespace.first.resource.registry\" to arguments\nTake the ServiceRegistry service identifier from the definitionId used earlier in \\App\\YourBundle::build()\n```php\n# src/YourBundle/Resources/config/services.php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ContainerConfigurator;\n\nreturn static function (ContainerConfigurator $configurator): void {\n    // ...\n    $services-\u003eset(\\App\\YourBundle\\Service\\SomeYourServiceUsingRegistry::class)\n        -\u003eargs([service('some.your.project.namespace.first.resource.registry')]);\n};\n```\n\nDeclare your service\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nnamespace App\\YourBundle;\n\nuse Highcore\\Component\\Registry\\IdentityServiceRegistryInterface;\n\nfinal class SomeYourServiceUsingRegistry\n{\n    public function __construct(private readonly Highcore\\Component\\Registry\\IdentityServiceRegistryInterface $registry)\n    {\n    }\n\n    public function someMethod()\n    {\n        // Retrieve all registered services\n        $yourServices = $this-\u003eregistry-\u003eall();\n\n        // Use the services\n    }\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhighcoreorg%2Fregistry-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhighcoreorg%2Fregistry-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhighcoreorg%2Fregistry-bundle/lists"}