PHP code example of kbondurant / attribute-container

1. Go to this page and download the library: Download kbondurant/attribute-container library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kbondurant / attribute-container example snippets


 

declare(strict_types=1);

$container = new League\Container\Container();
$delegate  = new Kbondurant\AttributeContainer\AttributeContainer();

$container->delegate($delegate);



declare(strict_types=1);

namespace Tests\Fixtures;

use Kbondurant\AttributeContainer\BindTo;

#[BindTo(Bar::class)]
interface Foo
{
    //
}



declare(strict_types=1);

namespace Tests\Fixtures;

use Kbondurant\AttributeContainer\BindTo;

#[BindTo(Bar::class, true)]
interface Foo
{
    //
}

#[Attribute]
class MyBindingAttribute implements Kbondurant\AttributeContainer\BindingAttribute
{
    /**
     * @param class-string $class
     */
    public function __construct(
        private string $class,
    ) {
    }

    public function getClass(): string
    {
        return $this->class;
    }

    public function isShared(): bool
    {
        return false;
    }
}

#[MyBindingAttribute(Bar::class)]
interface Foo
{
    //
}