Skip to content

Bind interfaces to implementations using attributes

Notifications You must be signed in to change notification settings

ornikar/attribute-binding

Repository files navigation

Attribute Binding

Declare interface bindings using attributes

Installation

Using composer

composer require ornikar/attribute-binding

Usage

<?php

declare(strict_types=1);

namespace Acme;

use Ornikar\AttributeBinding\BindTo;

#[BindTo(MyImplementation::class)]
interface MyInterface
{
    //
}

Declare binding as singleton:

<?php

declare(strict_types=1);

namespace Acme;

use Ornikar\AttributeBinding\BindingType;
use Ornikar\AttributeBinding\BindTo;

#[BindTo(MyImplementation::class, BindingType::Singleton)]
interface MyInterface
{
    //
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

Bind interfaces to implementations using attributes

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages