Download the PHP package koded/container without Composer
On this page you can find all versions of the php package koded/container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download koded/container
More information about koded/container
Files in koded/container
Package container
Short Description A simple Dependency Injection Container with application modules support
License BSD-3-Clause
Homepage https://github.com/kodedphp/container
Informations about the package container
Dependency Injection Container - Koded
koded/container
is an OOP application bootstrapping and wiring library.
In other words, Koded\DIContainer
implements a design pattern called Dependency Inversion.
The main principle of DIP is to separate the behavior from dependency resolution.
Example
Let's look at a blog application that has
- interfaces for the database repositories and corresponding implementations
- a shared PDO instance
- a service class for the blog content fetching
- a handler class that maps the request method
Somewhere we may have a service class that uses the dependent repositories:
Then somewhere we might have a handler/controller that asks for its own dependencies:
Wire All The Things
This is the bootstrapping / wiring application module (or container's "configuration" class) where all known dependencies are binded and shared
And finally in the dispatcher file, we process the request
The container implements the __invoke() method, so the instance can be used as a function:
To be continued...
Code quality
License
The code is distributed under the terms of The 3-Clause BSD license.