Skip to content

What is the goal of the service layer in Magento 2? #728

@joshdifabio

Description

@joshdifabio

The first thing I noticed about Magento 2 was the use of dependency injection. The second was probably the service layer, which is potentially just as exciting.

What is the goal of the service layer? Is it intended to provide a manageable and well-defined public API for each module, reducing the remainder of a module's functionality to an implementation detail? If achievable, such an approach would enable us to replace entire modules with different implementations, which would be excellent both in terms of interoperability and in terms of the potential to evolve the platform, but I'm not sure whether this aligns with your intentions for the service layer.

Along these lines, have you considered creating interfaces for the service data classes, e.g. \Magento\Catalog\Service\V1\Data\Product[Interface], and then having your model classes, e.g. \Magento\Catalog\Model\Product, implement those service interfaces in order to eliminate the burden of having to convert model objects to service data objects at runtime?

Currently, Magento 2's inter-module dependencies don't seem to be entirely isolated to the service layer but I'd be interested to know whether this is intended to change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions