commit | author | age
|
2207d6
|
1 |
Symfony Contracts |
W |
2 |
================= |
|
3 |
|
|
4 |
A set of abstractions extracted out of the Symfony components. |
|
5 |
|
|
6 |
Can be used to build on semantics that the Symfony components proved useful - and |
|
7 |
that already have battle tested implementations. |
|
8 |
|
|
9 |
Design Principles |
|
10 |
----------------- |
|
11 |
|
|
12 |
* contracts are split by domain, each into their own sub-namespaces; |
|
13 |
* contracts are small and consistent sets of PHP interfaces, traits, normative |
|
14 |
docblocks and reference test suites when applicable, ...; |
|
15 |
* all contracts must have a proven implementation to enter this repository; |
|
16 |
* they must be backward compatible with existing Symfony components. |
|
17 |
|
|
18 |
Packages that implement specific contracts should list them in the "provide" |
|
19 |
section of their "composer.json" file, using the `symfony/*-implementation` |
|
20 |
convention (e.g. `"provide": { "symfony/cache-implementation": "1.0" }`). |
|
21 |
|
|
22 |
FAQ |
|
23 |
--- |
|
24 |
|
|
25 |
### How to use this package? |
|
26 |
|
|
27 |
The abstractions in this package are useful to achieve loose coupling and |
|
28 |
interoperability. By using the provided interfaces as type hints, you are able |
|
29 |
to reuse any implementations that match their contracts. It could be a Symfony |
|
30 |
component, or another one provided by the PHP community at large. |
|
31 |
|
|
32 |
Depending on their semantics, some interfaces can be combined with autowiring to |
|
33 |
seamlessly inject a service in your classes. |
|
34 |
|
|
35 |
Others might be useful as labeling interfaces, to hint about a specific behavior |
|
36 |
that could be enabled when using autoconfiguration or manual service tagging (or |
|
37 |
any other means provided by your framework.) |
|
38 |
|
|
39 |
### How is this different from PHP-FIG's PSRs? |
|
40 |
|
|
41 |
When applicable, the provided contracts are built on top of PHP-FIG's PSRs. But |
|
42 |
the group has different goals and different processes. Here, we're focusing on |
|
43 |
providing abstractions that are useful on their own while still compatible with |
|
44 |
implementations provided by Symfony. Although not the main target, we hope that |
|
45 |
the declared contracts will directly or indirectly contribute to the PHP-FIG. |
|
46 |
|
|
47 |
Resources |
|
48 |
--------- |
|
49 |
|
|
50 |
* [Documentation](https://symfony.com/doc/current/components/contracts.html) |
|
51 |
* [Contributing](https://symfony.com/doc/current/contributing/index.html) |
|
52 |
* [Report issues](https://github.com/symfony/symfony/issues) and |
|
53 |
[send Pull Requests](https://github.com/symfony/symfony/pulls) |
|
54 |
in the [main Symfony repository](https://github.com/symfony/symfony) |