All Projects → bitExpert → Disco

bitExpert / Disco

Licence: apache-2.0
PSR-11 compatible Dependency Injection Container for PHP.

Projects that are alternatives of or similar to Disco

Di
Dependency Injection and IoC framework for PHP
Stars: ✭ 5 (-96.3%)
Mutual labels:  dependency-injection, ioc, ioc-container
Poodinis
A dependency injection framework for D with support for autowiring.
Stars: ✭ 57 (-57.78%)
Mutual labels:  dependency-injection, ioc, ioc-container
di
🛠 A full-featured dependency injection container for go programming language.
Stars: ✭ 156 (+15.56%)
Mutual labels:  ioc, dependency-injection, ioc-container
Reflex
Minimal dependency injection framework for Unity
Stars: ✭ 263 (+94.81%)
Mutual labels:  ioc, dependency-injection, ioc-container
brisk-ioc
fast light brisk ioc/di container on nodejs; Node下快速 轻量的IoC/DI容器,依赖注入,配合装饰器使用
Stars: ✭ 12 (-91.11%)
Mutual labels:  ioc, dependency-injection, ioc-container
SwiftInjection
Dependency Injection framework for Swift
Stars: ✭ 21 (-84.44%)
Mutual labels:  ioc, dependency-injection, ioc-container
Typescript Ioc
A Lightweight annotation-based dependency injection container for typescript.
Stars: ✭ 427 (+216.3%)
Mutual labels:  dependency-injection, ioc, ioc-container
Typhoon
Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
Stars: ✭ 2,711 (+1908.15%)
Mutual labels:  dependency-injection, ioc, ioc-container
Python Dependency Injector
Dependency injection framework for Python
Stars: ✭ 1,203 (+791.11%)
Mutual labels:  dependency-injection, ioc, ioc-container
alpha-dic
Powerful dependency injection container for node.js
Stars: ✭ 27 (-80%)
Mutual labels:  ioc, dependency-injection, ioc-container
vesselize
⛵ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-83.7%)
Mutual labels:  ioc, dependency-injection, ioc-container
Singularity
A extremely fast ioc container for high performance applications
Stars: ✭ 63 (-53.33%)
Mutual labels:  dependency-injection, ioc, ioc-container
iocgo
A lightweight Inversion of Control (IoC) (Dependency Injection) container for Golang
Stars: ✭ 36 (-73.33%)
Mutual labels:  ioc, dependency-injection, ioc-container
inject
[Archived] See https://github.com/goava/di.
Stars: ✭ 49 (-63.7%)
Mutual labels:  ioc, dependency-injection, ioc-container
ashley
Ashley is a dependency injection container for JavaScript.
Stars: ✭ 23 (-82.96%)
Mutual labels:  ioc, dependency-injection, ioc-container
DependencyInjector
Lightweight dependency injector
Stars: ✭ 30 (-77.78%)
Mutual labels:  ioc, dependency-injection, ioc-container
Container
A lightweight yet powerful IoC container for Go projects
Stars: ✭ 160 (+18.52%)
Mutual labels:  dependency-injection, ioc, ioc-container
Ioc
🦄 lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript
Stars: ✭ 171 (+26.67%)
Mutual labels:  dependency-injection, ioc, ioc-container
ThunderboltIoc
One of the very first IoC frameworks for .Net that has no reflection. An IoC that casts its services before thunder casts its bolts.
Stars: ✭ 40 (-70.37%)
Mutual labels:  ioc, dependency-injection, ioc-container
Kangaru
🦘 A dependency injection container for C++11, C++14 and later
Stars: ✭ 297 (+120%)
Mutual labels:  dependency-injection, ioc, ioc-container

bitexpert/disco

This package provides a PSR-11 compatible, annotation-based dependency injection container. Have a look at the disco-demos project to find out how to use Disco.

Build Status Coverage Status

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

$beanFactory = new \bitExpert\Disco\AnnotationBeanFactory(MyConfiguration::class);
\bitExpert\Disco\BeanFactoryRegistry::register($beanFactory);

Next up you need to create a configuration class MyConfiguration and document it with a @Configuration annotation.

<?php

use bitExpert\Disco\Annotations\Configuration;

/**
 * @Configuration
 */
class MyConfiguration
{
}

To declare a configuration entry, 1) add a method to your MyConfiguration class, and 2) annotate the method with the @Bean annotation. Doing this registers the instance with Disco and uses the type specified by the method’s return value. The primary identifier is the method name:

<?php

use bitExpert\Disco\Annotations\Bean;
use bitExpert\Disco\Annotations\Configuration;
use bitExpert\Disco\Helper\SampleService;

/**
 * @Configuration
 */
class MyConfiguration
{
    /**
     * @Bean
     */
    public function mySampleService() : SampleService
    {
        return new SampleService();
    }
}

To let Disco return the entry with the id mySampleService call the get() method of \bitExpert\Disco\AnnotationBeanFactory, as follows:

<?php

$beanFactory->get('mySampleService');

Documentation

Documentation is in the docs tree, and can be compiled using bookdown.

$ 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/

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 to find out how, as well as what we expect from you.

Resources

License

Disco is released under the Apache 2.0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].