codenamephp / platform.di Goto Github PK
View Code? Open in Web Editor NEWSimple dependency injection container based on www.php-di.org
License: Apache License 2.0
Simple dependency injection container based on www.php-di.org
License: Apache License 2.0
The interfaces like iContainer should have a default definition set that defaults to the container itself, pretty much like phpdi itself handles it
It's been a while since I put any amount of effort into this package (mostly because it still works like it's supposed to).
But some outdated stuff should be brought back up to speed:
Release Drafter should be added as workflow since it's very convenient.
When migrating to composition I forgot that addDefinitions (and maybe other public methods) might be in use and are not available in the interface anymore. Those should be added again and declared as deprecated if I don't want to support them in the future anymore.
There is a feature request to automatically add dependencies. Although I'm not a huge fan of it I understand the wish to only add the "top level providers" and have the dependencies added automatically.
After a release was created, the readme should be updated with the new tag in default branch as well as in the new tag itself.
There should be a way to auto configure libraries by adding a provider class to the builder.
1st step idea:
There a several provider interfaces, e.g. iGlobPathProvider, iDefinitionsProvider, ...
The current dependency check just collects the added dependencies in an array. If a provider is added its dependencies are checked against that array. If the dependency is missing an exception is thrown.
This has the advantage that the logic behind it is very easy and that missing dependencies are detected early. But it comes with the disadvantage that dependencies actually have to be added in the correct order which can be cumbersome when there a lot of providers and one might also group similar providers together for better readability.
One solution might be to collect the dependencies and then do a topological sort (possible candidate: https://github.com/marcj/topsort.php) before the container is built.
While comparatively complicated this would also have the nice bonus that the handling of the providers would have to be extracted from the container builder which is something I wanted to do anyway since adding a new provider type requires changes to the existing code and also makes testing more difficult.
Initial idea:
In addition to the autoconfiguraiton from issue #1 there should a way that the configurations are detected automaticly so they don't need to be added manually
array_diff would get rid of the if and make the function more readable.
The glob files should be discovered directly when they are added. Otherwise, they would always overwrite everything else as they are added last (on build).
Example:
$builder->addGlobPath(...); //would overwrite definitions in next line since the files are discovered and added later
$builder->addDefinitions([]); //would not overwrite definitions in glob
The container builder uses itself as class, not the container
platform.di/src/ContainerBuilder.php
Line 55 in 0ba6a15
It sometimes makes sense to spread definitions across multiple providers. To prevent having to add multiple classes or change the configuration when a new provider was added a MetaProvider interface that can add multiple providers at once would make sense
The dependency handling adds the class only if the iDependency interface exsists. If not, the class is never added to the existing dependencies. If another class depends on it the dependency can never be satisfied.
The class names of added providers should be recorder even if no interface is set. Otherwise, classes have to explicitly enabled to be dependencies which kind of defeats the purpose.
There should be a trait for the member and getter/setter using the iContainer interface
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.