Download the PHP package tobento/service-container without Composer
On this page you can find all versions of the php package tobento/service-container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tobento/service-container
More information about tobento/service-container
Files in tobento/service-container
Package service-container
Short Description A PSR-11 container with autowiring.
License MIT
Homepage https://www.tobento.ch
Informations about the package service-container
Container Service
The Container Service provides a PSR-11 container with autowiring.
Table of Contents
- Getting started
- Requirements
- Highlights
- Simple Example
- Documentation
- PSR-11
- Autowiring
- Definitions
- Make
- Call
- Resolver
- Credits
Getting started
Add the latest version of the container service running this command.
Requirements
- PHP 8.0 or greater
Highlights
- Framework-agnostic, will work with any project
- Decoupled design
- Autowiring
Documentation
PSR-11
Autowiring
The container resolves any dependencies by autowiring, except build-in parameters needs a definition to be resolved.
On union types parameter, the first resolvable parameter gets used if not set by definiton.
Definitions
By providing the resolved object:
By defining the missing parameters:
By using a closure:
The container will automatically resolve any closure arguments.
You might configure which implementation to use:
Defining method calls: You will need only to define build-in parameters as others get autowired if you want to.
Prototype Definition:
You might declare the defintion as prototype, meaning returning always a new instance.
Make
The make() method works like get() except it will resolve the entry every time it is called.
Call
For more detail visit: service-autowire#call
Resolver
You might adjust your requirements by adding a custom resolver which implements the following interface:
Credits
- Tobias Strub
- All Contributors