symfony / contracts
A set of abstractions extracted out of the Symfony components
Fund package maintenance!
fabpot
Tidelift
symfony.com/sponsor
Requires
- php: >=8.1
- psr/cache: ^3.0
- psr/container: ^1.1|^2.0
- psr/event-dispatcher: ^1.0
Requires (Dev)
- symfony/polyfill-intl-idn: ^1.10
Conflicts
- ext-psr: <1.1|>=2
Replaces
- symfony/cache-contracts: v3.5.2
- symfony/deprecation-contracts: v3.5.2
- symfony/event-dispatcher-contracts: v3.5.2
- symfony/http-client-contracts: v3.5.2
- symfony/service-contracts: v3.5.2
- symfony/translation-contracts: v3.5.2
- dev-main / 3.6.x-dev
- 3.5.x-dev
- v3.5.2
- v3.5.1
- v3.5.0
- 3.4.x-dev
- v3.4.4
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- 3.3.x-dev
- v3.3.0
- 3.2.x-dev
- v3.2.1
- v3.2.0
- 3.1.x-dev
- v3.1.1
- v3.1.0
- 3.0.x-dev
- v3.0.2
- v3.0.1
- v3.0.0
- 2.5.x-dev
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- 2.4.x-dev
- v2.4.1
- v2.4.0
- 2.3.x-dev
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0
- v1.10.0
- 1.1.x-dev
- v1.1.13
- v1.1.12
- v1.1.11
- v1.1.10
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-RC1
- v1.0.0-BETA1
This package is auto-updated.
Last update: 2024-12-11 16:51:52 UTC
README
A set of abstractions extracted out of the Symfony components.
Can be used to build on semantics that the Symfony components proved useful - and that already have battle tested implementations.
Design Principles
- contracts are split by domain, each into their own sub-namespaces;
- contracts are small and consistent sets of PHP interfaces, traits, normative docblocks and reference test suites when applicable;
- all contracts must have a proven implementation to enter this repository;
- they must be backward compatible with existing Symfony components.
Packages that implement specific contracts should list them in the "provide"
section of their "composer.json" file, using the symfony/*-implementation
convention (e.g. "provide": { "symfony/cache-implementation": "1.0" }
).
FAQ
How to use this package?
The abstractions in this package are useful to achieve loose coupling and interoperability. By using the provided interfaces as type hints, you are able to reuse any implementations that match their contracts. It could be a Symfony component, or another one provided by the PHP community at large.
Depending on their semantics, some interfaces can be combined with autowiring to seamlessly inject a service in your classes.
Others might be useful as labeling interfaces, to hint about a specific behavior that could be enabled when using autoconfiguration or manual service tagging (or any other means provided by your framework.)
How is this different from PHP-FIG's PSRs?
When applicable, the provided contracts are built on top of PHP-FIG's PSRs. But the group has different goals and different processes. Here, we're focusing on providing abstractions that are useful on their own while still compatible with implementations provided by Symfony. Although not the main target, we hope that the declared contracts will directly or indirectly contribute to the PHP-FIG.