php-etl / sylius-api-php-client
API client for Sylius API versions 1.6, 1.7, 1.9 and above.
Requires
- php: >=7.1
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.6
- php-http/httplug: ^1.1 || ^2.0
- php-http/message: ^1.7
- php-http/message-factory: ^v1.0
- php-http/multipart-stream-builder: ^1.0
- psr/http-client: ^1.0
- psr/http-message: ^1.0
- symfony/expression-language: ^3.0|^4.0|^5.0
Requires (Dev)
- donatj/mock-webserver: ^2.0
- friendsofphp/php-cs-fixer: ^2.14
- php-http/guzzle6-adapter: ^2.0
- phpspec/phpspec: ^5.0
- phpunit/phpunit: ^5.7
- symfony/yaml: ^4.2
Suggests
- php-http/guzzle6-adapter: In order to use Guzzle v6 as the HTTP client
This package is auto-updated.
Last update: 2024-11-17 16:08:57 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();