Skip to main content

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

Installation

$ pip install pyfony

Pyfony initialization

(The following steps are covered in the BaseKernelTest)

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

parameters:
  api:
    endpoint: 'https://api.mycompany.com'

services:
    mycompany.api.ApiClient:
      arguments:
        - '@mycompany.api.Authenticator'

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

Then, initialize the container:

from injecta.config.YamlConfigReader import YamlConfigReader
from pyfony.kernel.BaseKernel import BaseKernel

appEnv = 'dev'

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

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   
apiClient.get('/foo/bar')

Advanced examples

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

Metadata

Release files for pyfony 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pyfony 0.6.1
File Interpreter ABI Platform Actions
pyfony-0.6.1-py3-none-any.whl Python 3 none any Details for pyfony-0.6.1-py3-none-any.whl

Release files / pyfony-0.6.1-py3-none-any.whl

Download URL pyfony-0.6.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
709290846d3a7f17bbb1ce67e199951ab131e831264ee66dd98d2f09db0b0a56
BLAKE2b-256 checksum
How to use checksums
0327bd9cea5bf13af1865118dc1ece936914ee283929d08a60bb2be2618e9b5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.0 CPython/3.7.3 Linux/5.4.0-1026-azure

Security for pyfony 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page