Skip to content
/ DI Public

Dependency Injector for my projects

Notifications You must be signed in to change notification settings

Saso/DI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

DI - Simple Dependency injector

usage: It is singleton object with only DI::get() method:
Saso\DI::get( string $objDescriptor, array $params=[], string $context='production')

Example (app code):

<?php

// ..some code
// we need a Log object:
$log = Saso\DI::get('sysLog', ['log/sysLog.log'], 'production');
//..we can use it here
?>

Creator classes are part of your application and DI finds the classes just by their name (\DI\Creators\<your_class_here>)

DI/Creators/sysLog.php:

<?php
declare(strict_types=1);

namespace DI\Creators;

use Saso\DI\DI;

final class sysLog extends Base {
    public function production() {
        return new \Service\Log( $this->params[0] );
    }
}

About

Dependency Injector for my projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages