This document details the high-level technical workings of the amphp/injector project. Specifically, this document has 2 primary goals:
- Serve as a basis for more thorough documentation in the amphp/injecto repo proper.
- Serve as a technical guide for integrating with cspray/annotated-container.
Amphp Injector is split into a set of systems to define and construct your container. Composing these systems together allows you to wire an object graph with the following functionalities:
- Shared services
- Recursively autowiring service dependencies
- Specify injection parameters for constructor and method calls
- Specify a factory to be used for creating a service
- Preparing a service after construction
- ?????????
A Provider describes how to create a service or non-object value to be stored in the Container. A Provider also allows you to define any other Providers that might be depended upon. For example, a ServiceProvider could declare a dependency on DatabaseProvider to ensure a database connection service is available.
A Definition is... TBD
A Weaver defines how to determine arguments to use for a constructor or method call (?). Implementations allow recursively autowiring parameters, to define a parameter that should be pulled from the Container, or the direct value of the parameter.
- How precisely do Definition and Definitions fit into the Provider and Weaver?
- What is an "attribute" on a Definition?
- How to alias a service?
- How to define a factory for a service?
- How to prepare a service after construction?