Skip to content

A simple Python IOC based on Symfony Dependency Component

License

Notifications You must be signed in to change notification settings

pytheons/ioc

 
 

Repository files navigation

Python Simple Dependency Injection Container

This project is a simple port of the Symfony DependencyInjection lib available at https://github.com/symfony/dependency-injection

Status: Work In Progress

Usage

Create services.yml file, the file will contains different service definiton such as

parameters:
    foo.bar: argument 1

services:
    fake:
        class: tests.ioc.service.Fake
        arguments: 
            - "%foo.bar%"
        kargs:
            param: here a parameter
        calls:
             - [ set_ok, [ false ]]
             - [ set_ok, [ true ], {arg2: "arg"} ]

    foo:
        class: tests.ioc.service.Foo
        arguments: ["@fake", "#@weak_reference"]
        kargs: {}

    weak_reference:
        class: tests.ioc.service.WeakReference

Then to use and access a service just do

import ioc

container = ioc.build(['services.yml'])

foo = container.get('foo')

About

A simple Python IOC based on Symfony Dependency Component

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.9%
  • Other 1.1%