What are service contracts in Magento?
Magento service contracts are PHP interfaces that define stable APIs for modules and web services.
Lesson Content
Magento has the idea of what is known as “service contracts”. But what are they?
Simple: they are just a set of PHP interfaces!
Recapping what an interface is: it’s just a blueprint for a class to follow. For example, given this interface named Blueprint:
<?php
interface Blueprint {
public function implementThis(): string;
public function implementThat(): string;
}All this interface means is that when a class implements it, it must implement all of the functions of this interface. Note also how the interface functions don’t contain implementations. The...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.