Skip to content

Add container resolution modes #2263

Description

@brendt

A interesting question was raised in #2256 on how the container should resolve dependencies.

First, we should discuss the current situation: Tempest's container defaults to non-singletons. Whenever you ->get() a dependency from the container, it will create a new one, unless there's an explicit singleton definition for it (defined either with $container->singleton, an initializer with #[Singleton], or a class tagged with #[Singleton]).

Now there are three questions to discuss:

  • Can we design an API that makes it trivial for users to explicitly retrieve non-singleton objects, even though they have a singleton definition?
  • Can we make it so the container's default resolution strategy can be changed?
  • What should the default resolution strategy be?

Let's discuss

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions