symfony/service-contracts
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
psr/container | 2.0.2 | 3.55 kB | MIT | prod |
The symfony/service-contracts package provides a set of generic abstractions extracted from Symfony components. These abstractions primarily relate to writing services and can be used to build functionalities based on the proven semantics of Symfony components. These implementations have been tested in demanding scenarios, ensuring their reliability and efficacy.
In order to use symfony/service-contracts, the first step is to install it using composer. You can do this by running the following command in your project directory:
composer require symfony/service-contracts
Most of the time, a Symfony contract is an interface to be implemented by user-defined classes. For example, lets consider a LoggerInterface
contract. To use it, you write a class implementing the LoggerInterface
. Here is a simple example:
use Psr\Log\LoggerInterface;
class MyLogger implements LoggerInterface
{
public function log($level, $message, array $context = array())
{
// Your logging logic here
}
}
This is a simple example and your actual implementation may vary depending on your use case.
The symfony/service-contracts documentation is centrally located at the main Symfony Contracts README page, under the 'Service Contracts' section. You can find more information regarding the usage and implementation of these contracts at the following url: Symfony Service Contracts Documentation