A simple PHP client to use the Sylius PHP API.
IMPORTANT: Documentation is work in progress.
Compatibility matrix:
Sylius version(s) | API PHP Client version | PHP requirements | CI status |
---|---|---|---|
>= 1.6 <=1.7 | ^1.0 (master) | ^7.3 | |
1.8 | no support | ||
>= 1.9 | ^2.0 | ^8.0 |
Note that our PHP client is backward compatible with versions 1.6 and 1.7.
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.
<?php
$builder = new \Diglin\Sylius\ApiClient\SyliusAdminClientBuilder();
$client = $builder->buildAuthenticatedByPassword('johndoe', 'password');
$client->getProductApi()->all();
<?php
$builder = new \Diglin\Sylius\ApiClient\SyliusStoreClientBuilder();
$client = $builder->buildAuthenticatedByPassword('[email protected]', 'password');
$client->getProductApi()->all();
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();