Implement a client

Edit on GitHub

This document describes how to implement a client part of the Spryker Yves application layer.

To learn more about the Spryker applications and their layers, see Conceptual overview

How to implement a client

All clients have the same structure. There is always one class that represents a client. This is quite close to the facades which we use in Zed. This class is the entry point, and it usually delegates to concrete implementations placed in the optional subdirectories Search, Session, Storage, and Zed.

Pyz\Client\MyBundle\MyBundleClient The Client’s entry point.
Pyz\Client\MyBundle\MyBundleDependencyProvider A dependency provider to interact with other modules.
Pyz\Client\MyBundle\MyBundleFactory The Client’s factory.
Pyz\Client\MyBundle\Session\MyBundleSession A wrapper for the session.
Pyz\Client\MyBundle\Search\MyBundleSearch Contains search queries—for example, Elasticsearch ).
Pyz\Client\MyBundle\Storage\MyBundleStorage Gets data from the storage—for example, Redis).
Pyz\Client\MyBundle\Zed\MyBundleStub The stub connects to Zed’s corresponding gateway controller .

When you implement a client, the client does not know about Yves. Therefore, don’t use any class from Yves there; otherwise, you make the client non-reusable in a different context.

The client class uses a factory to create the other objects. These objects require a connecting client, which they get injected into the factory. For this purpose, the factory contains these prepared methods:

  • createSessionClient()
  • createZedRequestClient()
  • createStorageClient()
  • createSearchClient()