Skip to content

Commit 0b41280

Browse files
authored
Update README.md
1 parent 89ede25 commit 0b41280

File tree

1 file changed

+2
-147
lines changed

1 file changed

+2
-147
lines changed

README.md

Lines changed: 2 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Matrix compatibility:
88

99
| Sylius version(s) | API PHP Client version |CI status |
1010
|--------------------|-------------------------|--------------------------------------------------------------------------------------------------------------------------|
11-
| v1.6 | v1.0 |[![Build Status](https://travis-ci.org/akeneo/api-php-client.svg?branch=1.0)](https://travis-ci.org/akeneo/api-php-client)|
12-
| - | master |[![Build Status](https://travis-ci.org/akeneo/api-php-client.svg?branch=master)](https://travis-ci.org/akeneo/api-php-client)|
11+
| v1.6 | v1.0 ||
12+
| - | master ||
1313

1414
Note that our PHP client is backward compatible.
1515
For example, if your PIM is currently a v2.3, you can still use a 1.0 version of the PHP client. The new endpoints available in v2.3 will not be available in the v1.0 of the PHP client.
@@ -19,149 +19,4 @@ For example, if your PIM is currently a v2.3, you can still use a 1.0 version of
1919
* PHP >= 5.6
2020
* Composer
2121

22-
## Installation
2322

24-
We use HTTPPlug as the HTTP client abstraction layer.
25-
In this example, we will use [Guzzle](https://github.com/guzzle/guzzle) v6 as the HTTP client implementation.
26-
27-
`api-php-client` uses [Composer](http://getcomposer.org).
28-
The first step to use `api-php-client` is to download composer:
29-
30-
```bash
31-
$ curl -s http://getcomposer.org/installer | php
32-
```
33-
34-
Then, run the following command to require the library:
35-
```bash
36-
$ php composer.phar require akeneo/api-php-client php-http/guzzle6-adapter
37-
```
38-
39-
If you want to use another HTTP client implementation, you can check [here](https://packagist.org/providers/php-http/client-implementation) the full list of HTTP client implementations.
40-
41-
## Documentation
42-
43-
Full documentation is available on the [API website](https://api.akeneo.com/php-client/introduction.html).
44-
45-
## Getting started
46-
47-
### Initialise the client
48-
You first need to initialise the client with your credentials client id/secret and with your user/password.
49-
50-
If you don't have any client id, let's take a look at [this page](https://api.akeneo.com/documentation/security.html#authentication) to create it.
51-
52-
```php
53-
<?php
54-
55-
require_once __DIR__ . '/vendor/autoload.php';
56-
57-
$clientBuilder = new \Akeneo\Pim\ApiClient\SyliusClientBuilder('http://localhost/');
58-
$client = $clientBuilder->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
59-
```
60-
61-
You can authenticate to the client with your token/refresh token as well.
62-
```php
63-
$client = $clientBuilder->buildAuthenticatedByToken('client_id', 'secret', 'token', 'refresh_token');
64-
```
65-
66-
You can authenticate to the client with a custom header, in this case dummy client_id, secret, token and refresh token.
67-
```php
68-
$client = $clientBuilder->buildAuthenticatedByHeader(['X-AUTH-TOKEN' => 'qwertzuiopasdfghjkléxcvbnm']);
69-
```
70-
71-
Getting the token and refresh token is as simple as:
72-
```php
73-
$client->getToken();
74-
$client->getRefreshToken();
75-
```
76-
77-
### Get a product
78-
79-
```php
80-
$product = $client->getProductApi()->get('top');
81-
echo $product['identifier']; // display "top"
82-
```
83-
84-
### Get a list of products
85-
86-
#### By getting pages
87-
88-
```php
89-
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
90-
$searchBuilder->addFilter('enabled', '=', true);
91-
$searchFilters = $searchBuilder->getFilters();
92-
93-
$firstPage = $client->getProductApi()->listPerPage(50, true, ['search' => $searchFilters]);
94-
95-
echo $page->getCount();
96-
97-
foreach ($page->getItems() as $product) {
98-
// do your stuff here
99-
echo $product['identifier'];
100-
}
101-
102-
$nextPage = $page->getNextPage();
103-
104-
$firstPage = $nextPage->getPreviousPage();
105-
```
106-
107-
#### By getting a cursor
108-
109-
```php
110-
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
111-
$searchBuilder->addFilter('enabled', '=', true);
112-
$searchFilters = $searchBuilder->getFilters();
113-
114-
$products = $client->getProductApi()->all(50, ['search' => $searchFilters]);
115-
foreach ($products as $product) {
116-
// do your stuff here
117-
echo $product['identifier'];
118-
}
119-
```
120-
121-
### Create a product
122-
123-
```php
124-
$client->getProductApi()->create('top', ['enabled' => true]);
125-
```
126-
127-
### Upsert a product
128-
129-
```php
130-
$client->getProductApi()->upsert('top', ['family' => 'tshirt']);
131-
```
132-
133-
### Upsert a list of of products
134-
135-
```php
136-
$client->getProductApi()->upsertList([
137-
[
138-
'identifier' => 'top',
139-
'family' => 'tshirt',
140-
],
141-
[
142-
'identifier' => 'cap',
143-
'categories' => ['hat'],
144-
],
145-
]);
146-
```
147-
148-
## Testing
149-
150-
Do note that you have to delete the `composer.lock` because Doctrine dependencies are loaded.
151-
These dependencies are different in function of the PHP version running `composer install`.
152-
153-
```
154-
cp docker-compose.yml.dist docker-compose.yml
155-
rm -rf composer.lock vendor/
156-
docker-compose run client_56 composer install
157-
docker-compose run client_56 bin/phpunit -c phpunit.xml.dist
158-
docker-compose run client_56 bin/phpspec run
159-
docker-compose run client_56 bin/php-cs-fixer fix --diff --dry-run --config=.php_cs.php -vvv
160-
```
161-
162-
## Support
163-
164-
The support of this client is made in best effort by our Akeneo team.
165-
166-
If you find a bug or want to submit an improvement, don't hesitate to raise an issue on Github.
167-
Also, you can ask questions and discuss about the PHP client with the community in the [Slack User Group](https://akeneopim-ug.slack.com/messages/web-api/).

0 commit comments

Comments
 (0)