Service¶
A service is a class that encapsulates specific functionality, making it available to other parts of an application. Services are a core concept in modern PHP development, especially when using frameworks with dependency injection-based architectures.
A service bundles related logic, such as sending emails, logging, database access, into a single, reusable class.
Services are often injected into other classes or functions, rather than being instantiated directly. This promotes loose coupling and easier testing.
Services can be used across different parts of an application, reducing code duplication.
Services are typically configured and managed by a service container.
See also Mastering Symfony Service Container: Modern PHP Attributes Edition.
Related : Encapsulation, Dependency Injection, Service Container, Business Logic, Downtime, Lightweight Directory Access Protocol (LDAP), Value Object