Skip to content

Capsule

Garrett W edited this page Aug 31, 2021 · 3 revisions

capsulephp/di

Features in brief

  • Auto-wiring
  • Built-in factory callback functionality
  • Post-instantiation method calls / modification / decoration / setter injection
  • Class substitutions
  • Lazy-resolving ctor params, such as env vars, container objects, post- method calls, etc.
  • Named instances and storing outside values/objects in the container are trivial
  • Definition provider interface for classes that will work with the Definitions object to provide rules

Principles

Configuration details

  • Definitions object uses magic methods to set rules as if their class names were the names of object properties, along with a fluent interface
  • Ctor params can be configured by position, name, or type

My opinions

  • Using magic methods for setting stuff in this way is a bit unnatural so I probably wouldn't do it.
  • Definition provider interface is definitely a good idea. It enables modules of code to be easily plugged into the container.

Clone this wiki locally