Skip to main content

Dependency Injection powered framework

Project description

Pyfony framework

Pyfony is a Dependency Injection (DI) powered framework written in Python greatly inspired by the Symfony Framework in PHP & Spring Framework in Java.

The DI functionality is provided by the Injecta Dependency Injection Container.

Pyfony = Injecta + bundles (extensions) API


$ pip install pyfony

Pyfony initialization

(The following steps are covered in the PyfonyBundleTest)

To start using Pyfony, create a simple config_dev.yaml file to define your DI services:

    endpoint: ''

        - '@mycompany.api.Authenticator'

      class: mycompany.authenticator.RestAuthenticator
        - '%api.endpoint%'
        - '%env(API_TOKEN)%'

Then, initialize the container:

from injecta.config.YamlConfigReader import YamlConfigReader
from pyfony.Kernel import Kernel
from pyfonybundles.loader import pyfonyBundlesLoader

appEnv = 'dev'

kernel = Kernel(
    '/config/dir/path', # must be directory, not the config_dev.yaml file path!

container = kernel.initContainer()

Use container.get() to finally retrieve your service:

from mycompany.api.ApiClient import ApiClient

apiClient = container.get('mycompany.api.ApiClient') # type: ApiClient   

Advanced examples

  1. Advanced services configuration using Injecta
  2. Extending Pyfony with bundles

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyfony, version 0.7.0a2
Filename, size File type Python version Upload date Hashes
Filename, size pyfony-0.7.0a2-py3-none-any.whl (7.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyfony-0.7.0a2.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page