Download the PHP package grifart/nette-scoped-di without Composer
On this page you can find all versions of the php package grifart/nette-scoped-di. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download grifart/nette-scoped-di
More information about grifart/nette-scoped-di
Files in grifart/nette-scoped-di
Package nette-scoped-di
Short Description Multiple DI containers support for Nette DI
License MIT
Informations about the package nette-scoped-di
Nette Scoped Depenedency Injection Container
Split your app dependency injection container into well-defined scopes and enforce relationships between them.
On the edge between monolith and microservices
This approach stays in the middle of monolith and microservices.
From architectonical perspective it is equavalent to microservices approach. There is clear boundary and interface between model and app.
Technically you save tons of hours of maintainace cost of managing microservices. Because there is still one app, but with many independent modules. They have clear boundaries and explicitly defined dependencies. And when you break this boundary, you get an exception.
So if needed you can easily turn already defined modules into microservices later. Only part that is missing here is a serialization & networking stack. This can be easily solved by adding RPC layer between modules that are extracted into microservices.
More resources:
- 🎥 Jan Kuchar: Why you need to have more then one DI (english)
- 🎥 Live stream of Jan Tvrdik's talk (Czech only)
Example
You have a model where you want to expose access only to a few facades. So you export them from the model container into the app container, and the app then can only access those exported services. This means that app can no longer ignore ACL rules or directly access a database.
Registering the model into a user DI container
For the model container, you must create a DI extension to register all the services exported from the model to the user's application (UI/API/CLI/...) part of the app.
In the user DI container, register this newly created extension:
Exporting a service from the model container
Requiring a dependency of the model container
When the model container needs a dependency (EmailSender), it can require it by defining the service torso.
Then tell the DI that the outer container MUST provide the EmailSender.
The outer container then registers the service, and you are done.
Danger zone
Sometimes, you need to break the pattern of being insulated from the model. See danger zone.
Contributing
This repository is fork of mangoweb-backend/nette-di-scope.
Primary development place is gitlab.grifart.cz. master
is automatically replicated back to github:grifart/nette-di-scope.
Submitting contribution into fork
Internal contributions
Use GitLab and open merge request, target: master
. After merge it will be automatically propagated to GitHub.
External contributions
External developers: Use GitHub, open pull request targeting our master master
.
Internal reviewer and maintainer of pull request:
- fetch changes to local repo
- then merge into local
master
- push local master into
gitlab/master
(this will be automatically propagated to GitHub) - remove branches that are not needed anymore