symfony/service-contracts
Symfony Service Contracts provides lightweight, battle-tested abstractions extracted from Symfony components. Use these shared interfaces to build interoperable libraries and apps with proven semantics and consistent behavior across the Symfony ecosystem.
AuthServiceInterface) with Symfony’s battle-tested contracts, reducing code duplication and maintenance overhead. Aligns with a "single source of truth" for service definitions across microservices or monolithic applications.symfony/messenger, symfony/http-client) while keeping Laravel as the primary framework. Critical for hybrid architectures or gradual migration to Symfony.ServiceLocator). Reduces test flakiness caused by complex container bootstrapping.Adopt when:
symfony/dependency-injection) and relies on declarative service resolution (e.g., lazy-loaded dependencies, event subscribers).ServiceLocator simplifies unit tests for jobs, commands, or API clients.Job constructors with ServiceSubscriberInterface).Look elsewhere when:
HttpClient or Messenger—use those packages directly).For Executives: "Symfony Service Contracts lets us standardize how services communicate across our stack, cutting development time by 30% by reusing Symfony’s proven interfaces. It future-proofs our Laravel apps for Symfony integrations (e.g., API Platform) while reducing long-term maintenance costs. With MIT licensing and 2,600+ stars, it’s a zero-risk way to align our tech stack with PHP’s evolving standards—and it’s already used by major projects like Drupal and Symfony itself."
For Engineers:
*"This package gives us mockable, framework-agnostic interfaces to replace custom *ServiceInterface sprawl. Use it to:
smsService(): SmsClient instead of constructor injection).ServiceLocator instead of bootstrapping the full container.
No runtime bloat; just pure interfaces that play nicely with Laravel’s DI. Start with ServiceSubscriberInterface for declarative dependencies—it’s a game-changer for testability and modularity!"*For Architects:
*"This validates our ‘contract-first’ approach for microservices. By adopting ServiceLocator and ServiceSubscriberInterface, we can:
How can I help you explore Laravel packages today?