Comments (13)
So my initial thought here is the new "cool" kids on the block https://packagist.org/packages/bitexpert/disco would be good for this. They have a psr-11 version which is the hottest of beep.
from kickasscommerce.
Hmm ok but is ease of use really more important than the name?
from kickasscommerce.
If you do not end up using a DI container that does some auto-wiring magic, you will end up with a lot of configuration code anyways, may it be PHP code, XML, YAML or something else.
In Disco you would need one configuration method per dependency that needs to be managed by the DI container. Currently we only support one configuration to avoid clashing method names. You can however use traits to structure your configuration and for example maintain a module specific configuration. Usually you do not need many "global" dependencies like database connectors. In a lot of cases you could simply focus on the configuration trait available in the module your are working in.
Does that make sense to you? Maybe this presentation about Disco will give you some more insights.
from kickasscommerce.
@sandermangel sure, not a problem at all. If you need some more insights or a demo ping me. Happy to help.
from kickasscommerce.
@shochdoerfer, no problem at all. We haven't decided on a DI library yet but I've used Disco before, I simply want to play around with DICE to see which is the best fit for the project.
from kickasscommerce.
I looked a bit around and http://php-di.org/ does have ease of use.
Disco can probably do more but the whole syntax does have quite a learning curve, php-di seems to do stuff automagically based on the type-hint
from kickasscommerce.
Being the driving force behind Disco I might be a bit biased ;)
For regular use cases Disco is not that complicated to learn: Add a method to a config class, add the @bean annotation and you are good to go. Most of the DI containers out there do not really solve the DI problem, internally in the configuration they are used as service locators which comes with its own problems - technically you depend on a string rather than a concrete type, no explicit type checking possible etc. This is a problem that Disco solves.
In case you think Disco is too complicated to learn I would love to get some ideas how we could simplify things to make it more "usable".
from kickasscommerce.
@shochdoerfer thanks for explaining the vision behind it. I like that!
What I'm curious about, and forgive my absolute lack of knowledge on DI, is in my mind most classes and methods need dependencies.
Wont' that give us tons of config classes with methods and a lot of places you need to configure stuff in order to inject your own dependencies?
from kickasscommerce.
@shochdoerfer I think I need to spent some sunday afternoon on this. thanks for explaining :)
from kickasscommerce.
Recommended by Vinai we have another candidate: https://github.com/Level-2/Dice
from kickasscommerce.
So, another twist: DI via Factories. Not using containers (see pumpkins and lizards code)
from kickasscommerce.
Dice looks really good. I'm going to self assign this one and try DICE out. Unless @dmanners has made any progress.
from kickasscommerce.
@adam-paterson if it isn't too much extra work I would love to get some insights if and what makes Disco compared to Dice hard to use for your use-case.
from kickasscommerce.
Related Issues (20)
- The repo knows to much
- We suck at FE HOT 1
- We suck at designing logos HOT 6
- Lots of * in the composer.json HOT 1
- Add build processes and code checks to the repo
- Standardise APIs HOT 2
- Invalid cache key HOT 1
- Is AOP a bad thing? HOT 6
- Is SlimPHP the best solution for routing HOT 1
- Are we a lib or a framework? HOT 9
- Session data - how do the cool kids/frameworks handle that? HOT 1
- A bit of admin HOT 7
- Move Moltin bridge to it's own repo HOT 1
- move to Moltin V2 API HOT 3
- Composer.lock should be not in the repo, the project should require PHP 7
- Make maps Immutable HOT 2
- Add fancy interceptors HOT 1
- Remove hardcoded dependencies to Moltin in router HOT 3
- Make the cache interceptor wrap bridge class methods instead of repositories
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kickasscommerce.