GithubHelp home page GithubHelp logo

Comments (13)

dmanners avatar dmanners commented on June 19, 2024 1

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.

dmanners avatar dmanners commented on June 19, 2024 1

Hmm ok but is ease of use really more important than the name?

from kickasscommerce.

shochdoerfer avatar shochdoerfer commented on June 19, 2024 1

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.

shochdoerfer avatar shochdoerfer commented on June 19, 2024 1

@sandermangel sure, not a problem at all. If you need some more insights or a demo ping me. Happy to help.

from kickasscommerce.

adam-paterson avatar adam-paterson commented on June 19, 2024 1

@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.

sandermangel avatar sandermangel commented on June 19, 2024

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.

shochdoerfer avatar shochdoerfer commented on June 19, 2024

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.

sandermangel avatar sandermangel commented on June 19, 2024

@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.

sandermangel avatar sandermangel commented on June 19, 2024

@shochdoerfer I think I need to spent some sunday afternoon on this. thanks for explaining :)

from kickasscommerce.

sandermangel avatar sandermangel commented on June 19, 2024

Recommended by Vinai we have another candidate: https://github.com/Level-2/Dice

from kickasscommerce.

sandermangel avatar sandermangel commented on June 19, 2024

So, another twist: DI via Factories. Not using containers (see pumpkins and lizards code)

from kickasscommerce.

adam-paterson avatar adam-paterson commented on June 19, 2024

Dice looks really good. I'm going to self assign this one and try DICE out. Unless @dmanners has made any progress.

from kickasscommerce.

shochdoerfer avatar shochdoerfer commented on June 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.