Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bitExpert/disco

PSR-11 compatible Dependency Injection Container for PHP.
https://github.com/bitExpert/disco

container-interop dependency-injection dependency-injection-container disco php psr-11

Last synced: 4 days ago
JSON representation

PSR-11 compatible Dependency Injection Container for PHP.

Awesome Lists containing this project

README

        

# bitexpert/disco

This 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.

[![Build Status](https://github.com/bitExpert/disco/workflows/ci/badge.svg?branch=master)](https://github.com/bitExpert/disco/actions)
[![Coverage Status](https://coveralls.io/repos/github/bitExpert/disco/badge.svg?branch=master)](https://coveralls.io/github/bitExpert/disco?branch=master)
[![Mastodon Follow](https://img.shields.io/mastodon/follow/109408681246972700?domain=https://rheinneckar.social)](https://rheinneckar.social/@bitexpert)

## Installation

The preferred way of installing `bitexpert/disco` is through Composer.
You can add `bitexpert/disco` as a dependency, as follows:

```
composer.phar require bitexpert/disco
```

## Usage

To instantiate Disco use the following code in your bootstrapping logic.
Create an instance of the `\bitExpert\Disco\AnnotationBeanFactory` and register the instance with the `\bitExpert\Disco\BeanFactoryRegistry`.
The 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.

```php
get('mySampleService');
```

## Documentation

Documentation is [in the docs tree](docs/), and can be compiled using [bookdown](http://bookdown.io).

```console
$ php ./vendor/bin/bookdown docs/bookdown.json
$ php -S 0.0.0.0:8080 -t docs/html/
```

Then point your browser to [http://localhost:8080/](http://localhost:8080/)

## Contribute

Please 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.

## Want To Contribute?

If you feel that you have something to share, then we’d love to have you.
Check out [the contributing guide](CONTRIBUTING.md) to find out how, as well as what we expect from you.

## Resources

- 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/)
- php[architect]: [Education Station: Your Dependency Injection Needs a Disco](https://www.phparch.com/magazine/2016-2/september/)
- Presentation: [Disco - A Fresh Look at DI](https://talks.bitexpert.de/phpugffm16-disco/) at [PHPUGFFM V/2016](http://www.phpugffm.de)

## License

Disco is released under the Apache 2.0 license.