ProductPromotion
Logo

PHP

made by https://0x3d.site

GitHub - bitExpert/disco: PSR-11 compatible Dependency Injection Container for PHP.
PSR-11 compatible Dependency Injection Container for PHP. - bitExpert/disco
Visit Site

GitHub - bitExpert/disco: PSR-11 compatible Dependency Injection Container for PHP.

GitHub - bitExpert/disco: PSR-11 compatible Dependency Injection Container for PHP.

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 Mastodon Follow

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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory