php-etl/sylius-api-php-client

API client for Sylius API versions 1.6, 1.7, 1.9 and above.

1.2.4 2021-02-10 12:27 UTC

README

A simple PHP client to use the Sylius PHP API.

IMPORTANT: Documentation is work in progress.

Compatibility matrix:

Note that our PHP client is backward compatible with versions 1.6 and 1.7.

Usage for API v2 (Sylius >= 1.9)

In Sylius versions 1.9 and later, you will be using the v2 API, or Unified API. This APU will expose 2 sections:

  • the Shop API, for accessing data from the customer's point of view
  • the Admin API, for accessing data from an administrator point of view

Additionally, you can activate the now deprecated v1 Admin API.

To create your client, there is a client builder for each API that will take care for you of the internals and dependency injection.

Admin API usage

<?php

$builder = new \Diglin\Sylius\ApiClient\SyliusAdminClientBuilder();

$client = $builder->buildAuthenticatedByPassword('johndoe', 'password');
$client->getProductApi()->all();

Store API usage

<?php

$builder = new \Diglin\Sylius\ApiClient\SyliusStoreClientBuilder();

$client = $builder->buildAuthenticatedByPassword('johndoe@example.com', 'password');
$client->getProductApi()->all();

Usage for API v1 (Sylius >= 1.6 <=1.7, deprecated after 1.7)

NOTE: If you are using Sylius version >= 1.10, you will need to reactivate this API following this documentation: https://docs.sylius.com/en/1.10/book/api/introduction.html?highlight=sylius_api

To create your client, there is a client builder that will take care for you of the internals and dependency injection.

<?php

$builder = new \Diglin\Sylius\ApiClient\SyliusLegacyClientBuilder();

$client = $builder->buildAuthenticatedByPassword('johndoe', 'password', '<api key>', '<api secret>');
$client->getProductsApi()->all();