maxa-ondrej/nette-di

Nette Framework better DI

1.1.1 2022-08-27 13:43 UTC

This package is auto-updated.

Last update: 2024-10-27 18:49:40 UTC


README

Usage

composer require maxa-ondrej/nette-di

Nette Framework Usage

config.neon

extensions:
    better-di: Maxa\Ondrej\Nette\DI\DIExtension
<?php declare(strict_types=1);

use Maxa\Ondrej\Nette\DI\Parameter;
use Maxa\Ondrej\Nette\DI\Service;

#[Service]
class MyService {

    #[Parameter('app.url')]
    public string $url;
    
}

#[Service(
    name: 'my.epic.service',
    tags: 'cache',
    setup: '$object->setDebugMode($container->getParameters()["debugMode"]);',
    autostart: true,
    autowired: true
)]
class NamedService {

    private bool $debugMode = true;

    public function setDebugMode(bool $debugMode): void {
        $this->debugMode = $debugMode;
    }
    
}