{"id":18840597,"url":"https://github.com/bitexpert/disco","last_synced_at":"2025-04-06T02:10:00.763Z","repository":{"id":47717645,"uuid":"45353612","full_name":"bitExpert/disco","owner":"bitExpert","description":"PSR-11 compatible Dependency Injection Container for PHP.","archived":false,"fork":false,"pushed_at":"2024-04-06T09:09:19.000Z","size":602,"stargazers_count":139,"open_issues_count":10,"forks_count":17,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-30T01:08:13.584Z","etag":null,"topics":["container-interop","dependency-injection","dependency-injection-container","disco","php","psr-11"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitExpert.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":"CONTRIBUTING.md","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":"2015-11-01T19:11:18.000Z","updated_at":"2024-09-15T12:53:44.000Z","dependencies_parsed_at":"2024-06-19T05:35:52.493Z","dependency_job_id":null,"html_url":"https://github.com/bitExpert/disco","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitExpert%2Fdisco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitExpert%2Fdisco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitExpert%2Fdisco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitExpert%2Fdisco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitExpert","download_url":"https://codeload.github.com/bitExpert/disco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423515,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["container-interop","dependency-injection","dependency-injection-container","disco","php","psr-11"],"created_at":"2024-11-08T02:48:14.641Z","updated_at":"2025-04-06T02:10:00.747Z","avatar_url":"https://github.com/bitExpert.png","language":"PHP","readme":"# bitexpert/disco\n\nThis package provides a [PSR-11](http://www.php-fig.org/psr/psr-11/) compatible, annotation-based dependency injection container. Have a look at the [disco-demos](https://github.com/bitExpert/disco-demos) project to find out how to use Disco.\n\n[![Build Status](https://github.com/bitExpert/disco/workflows/ci/badge.svg?branch=master)](https://github.com/bitExpert/disco/actions)\n[![Coverage Status](https://coveralls.io/repos/github/bitExpert/disco/badge.svg?branch=master)](https://coveralls.io/github/bitExpert/disco?branch=master)\n[![Mastodon Follow](https://img.shields.io/mastodon/follow/109408681246972700?domain=https://rheinneckar.social)](https://rheinneckar.social/@bitexpert)\n\n## Installation\n\nThe preferred way of installing `bitexpert/disco` is through Composer.\nYou can add `bitexpert/disco` as a dependency, as follows:\n\n```\ncomposer.phar require bitexpert/disco\n```\n\n## Usage\n\nTo instantiate Disco use the following code in your bootstrapping logic.\nCreate an instance of the `\\bitExpert\\Disco\\AnnotationBeanFactory` and register the instance with the `\\bitExpert\\Disco\\BeanFactoryRegistry`.\nThe second step is important as Disco needs to grab the active container instance in a few locations where it does not have access to the container instance itself.\n\n```php\n\u003c?php\n\n$beanFactory = new \\bitExpert\\Disco\\AnnotationBeanFactory(MyConfiguration::class);\n\\bitExpert\\Disco\\BeanFactoryRegistry::register($beanFactory);\n```\n\nNext up you need to create a configuration class `MyConfiguration` and document it with a `@Configuration` annotation.\n\n```php\n\u003c?php\n\nuse bitExpert\\Disco\\Annotations\\Configuration;\n\n/**\n * @Configuration\n */\nclass MyConfiguration\n{\n}\n```\n\nTo declare a configuration entry, 1) add a method to your `MyConfiguration` class, and 2) annotate the method with the `@Bean` annotation.\nDoing this registers the instance with Disco and uses the type specified by the method’s return value. The primary identifier is the method name:\n\n```php\n\u003c?php\n\nuse bitExpert\\Disco\\Annotations\\Bean;\nuse bitExpert\\Disco\\Annotations\\Configuration;\nuse bitExpert\\Disco\\Helper\\SampleService;\n\n/**\n * @Configuration\n */\nclass MyConfiguration\n{\n    /**\n     * @Bean\n     */\n    public function mySampleService() : SampleService\n    {\n        return new SampleService();\n    }\n}\n```\n\nTo let Disco return the entry with the id `mySampleService` call the `get()` method of `\\bitExpert\\Disco\\AnnotationBeanFactory`, as follows:\n\n```php\n\u003c?php\n\n$beanFactory-\u003eget('mySampleService');\n```\n\n## Documentation\n\nDocumentation is [in the docs tree](docs/), and can be compiled using [bookdown](http://bookdown.io).\n\n```console\n$ php ./vendor/bin/bookdown docs/bookdown.json\n$ php -S 0.0.0.0:8080 -t docs/html/\n```\n\nThen point your browser to [http://localhost:8080/](http://localhost:8080/)\n\n## Contribute\n\nPlease feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and adapt the documentation.\n\n## Want To Contribute?\n\nIf you feel that you have something to share, then we’d love to have you.\nCheck out [the contributing guide](CONTRIBUTING.md) to find out how, as well as what we expect from you.\n\n## Resources\n\n - sitepoint.com: [Disco with Design Patterns: A Fresh Look at Dependency Injection](https://www.sitepoint.com/disco-with-frameworks-and-design-patterns-a-fresh-look-at-dependency-injection/)\n - php[architect]: [Education Station: Your Dependency Injection Needs a Disco](https://www.phparch.com/magazine/2016-2/september/)\n - Presentation: [Disco - A Fresh Look at DI](https://talks.bitexpert.de/phpugffm16-disco/) at [PHPUGFFM V/2016](http://www.phpugffm.de)\n\n## License\n\nDisco is released under the Apache 2.0 license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitexpert%2Fdisco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitexpert%2Fdisco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitexpert%2Fdisco/lists"}