PHP code example of dotkernel / dot-dependency-injection

1. Go to this page and download the library: Download dotkernel/dot-dependency-injection 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/ */

    

dotkernel / dot-dependency-injection example snippets


Dot\DependencyInjection\ConfigProvider::class,

return [
    'factories' => [
        ServiceClass::class => AttributedServiceFactory::class,
    ],
];

#[Inject(
    App\Srevice\Dependency1::class,
    App\Srevice\Dependency2::class,
    "config",
)]
public function __construct(
    protected App\Srevice\Dependency1 $dep1,
    protected App\Srevice\Dependency2 $dep2,
    protected array $config
) {
}

#[Inject(
    "config.debug",
)]

return [
    'factories' => [
        ExampleRepository::class => AttributedRepositoryFactory::class,
    ],
];

use Api\App\Entity\Example;
use Doctrine\ORM\EntityRepository;
use Dot\DependencyInjection\Attribute\Entity;

#[Entity(name: Example::class)]
class ExampleRepository extends EntityRepository
{
}