Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 1aa57cb

Browse files
author
Jens Schulze
committed
Merge branch 'release/RC1'
2 parents 9d6e796 + 4d3c1ff commit 1aa57cb

File tree

764 files changed

+18382
-5274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

764 files changed

+18382
-5274
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.php eol=lf
2+

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
.vagrant
22
.idea
3-
vendor
4-
build
3+
/vendor
4+
/build/*
5+
!/build/theme
6+
!/build/apigen.neon
57
cache.properties
68
apigen.phar
79
composer.phar
810
composer.lock
911
myapp.ini
10-
local/
12+
/local/
13+
/tools/node_modules

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cache:
2020

2121
before_script:
2222
- composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN
23-
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
23+
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] ; then echo 'extension = redis.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; fi"
2424
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ] && [ `php-config --vernum` -ge 50500 ] ; then pecl config-set preferred_state beta; printf "yes\n" | pecl install -f apcu ; else echo 'extension="apc.so"' >> ./tests/apc.ini ; fi"
2525
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ] ; then phpenv config-add ./tests/apc.ini; fi"
2626
- if [ $TRAVIS_PHP_VERSION == '5.4' ] ; then ./set_guzzle5.sh; fi

CHANGELOG.md

Lines changed: 254 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,257 @@
1-
# SPHERE.IO PHP SDK Changelog
1+
<a name"1.0.0-RC1"></a>
2+
### 1.0.0-RC1 (2015-07-27)
23

3-
### 1.0.0 Milestone 3
4+
5+
#### Bug Fixes
6+
7+
* **CustomerCreateRequest:** set correct return object class ([d1c100c9](https://github.com/sphereio/sphere-php-sdk/commit/d1c100c9), closes [#109](https://github.com/sphereio/sphere-php-sdk/issues/109))
8+
* **Requests:** fix the usage of relative path by requests ([e32d0150](https://github.com/sphereio/sphere-php-sdk/commit/e32d0150))
9+
* **Order:** set correct return type for order discountCodes ([5bbf4f14](https://github.com/sphereio/sphere-php-sdk/commit/5bbf4f14))
10+
11+
12+
#### Features
13+
14+
* **AnnotationGenerator:** add magic method getAt and current with correct type hint to collections ([324886db](https://github.com/sphereio/sphere-php-sdk/commit/324886db))
15+
* **Attribute:** add feature to set attribute type definitions to attributes ([37546b33](https://github.com/sphereio/sphere-php-sdk/commit/37546b33))
16+
* **AttributeCollection:** add feature to set attribute type definitions to attribute collection ([af3b558a](https://github.com/sphereio/sphere-php-sdk/commit/af3b558a))
17+
* **CartDiscount:** add update actions ([c0e27dd5](https://github.com/sphereio/sphere-php-sdk/commit/c0e27dd5))
18+
* **Channel:**
19+
* add product distribution channel to line items and channel roles ([fdc4ed82](https://github.com/sphereio/sphere-php-sdk/commit/fdc4ed82), closes [#120](https://github.com/sphereio/sphere-php-sdk/issues/120))
20+
* add update actions ([b355e9aa](https://github.com/sphereio/sphere-php-sdk/commit/b355e9aa))
21+
* **Client:** add named constructor to Client and Config object ([1a0c350f](https://github.com/sphereio/sphere-php-sdk/commit/1a0c350f), closes [#101](https://github.com/sphereio/sphere-php-sdk/issues/101))
22+
* **Comments:** add update actions ([54804bf1](https://github.com/sphereio/sphere-php-sdk/commit/54804bf1))
23+
* **CustomerGroups:** add update actions ([30789b76](https://github.com/sphereio/sphere-php-sdk/commit/30789b76))
24+
* **DiscountCodes:** add update actions ([e3357965](https://github.com/sphereio/sphere-php-sdk/commit/e3357965))
25+
* **Exceptions:** wrap http client exceptions ([a169611b](https://github.com/sphereio/sphere-php-sdk/commit/a169611b))
26+
* **Inventory:** add update actions ([12ea56d5](https://github.com/sphereio/sphere-php-sdk/commit/12ea56d5))
27+
* **JsonObject:** add magic getter to access object data as property ([7a22cfa7](https://github.com/sphereio/sphere-php-sdk/commit/7a22cfa7))
28+
* **ProductDiscounts:** add update actions ([24bd9afb](https://github.com/sphereio/sphere-php-sdk/commit/24bd9afb))
29+
* **ProductTypes:** add update actions ([50616ef8](https://github.com/sphereio/sphere-php-sdk/commit/50616ef8))
30+
* **Project:** add project fetch request ([4e8d232c](https://github.com/sphereio/sphere-php-sdk/commit/4e8d232c), closes [#35](https://github.com/sphereio/sphere-php-sdk/issues/35))
31+
* **Requests:**
32+
* add executeWithClient and mapResponse function with correct type hints ([8cb1b2cc](https://github.com/sphereio/sphere-php-sdk/commit/8cb1b2cc))
33+
* add withTotal flag for query speed optimization ([b7892401](https://github.com/sphereio/sphere-php-sdk/commit/b7892401))
34+
* **Review:** add update actions ([4f1d55c8](https://github.com/sphereio/sphere-php-sdk/commit/4f1d55c8))
35+
* **ShippingMethod:**
36+
* add update actions ([46993be2](https://github.com/sphereio/sphere-php-sdk/commit/46993be2))
37+
* add shipping method getByCartId and getByLocation ([cb522923](https://github.com/sphereio/sphere-php-sdk/commit/cb522923))
38+
* **State:** add update actions ([3833ad1d](https://github.com/sphereio/sphere-php-sdk/commit/3833ad1d))
39+
* **TaxCategory:** add update actions ([428ba25a](https://github.com/sphereio/sphere-php-sdk/commit/428ba25a))
40+
* **Zones:** add update actions ([a74c3517](https://github.com/sphereio/sphere-php-sdk/commit/a74c3517))
41+
42+
43+
#### Breaking Changes
44+
45+
* QueryRequests renamed to singular form
46+
47+
To streamline the naming schemes between the SDKs QueryRequests have been renamed to their singular form. E.g.:
48+
49+
Before:
50+
51+
```
52+
$request = CategoriesQueryRequest::of();
53+
```
54+
55+
After:
56+
57+
```
58+
$request = CategoryQueryRequest::of();
59+
```
60+
61+
([8de23283](https://github.com/sphereio/sphere-php-sdk/commit/8de23283))
62+
* SingleResourceResponse renamed to ResourceResponse
63+
64+
To streamline the naming schemes between the SDKs SingleResourceResponse has been renamed to ResourceResponse
65+
66+
([4199c815](https://github.com/sphereio/sphere-php-sdk/commit/4199c815))
67+
* ImportLineItem renamed to LineItemImportDraft
68+
69+
To streamline the naming schemes between the SDKs ImportProductVariant, ImportLineItem and ImportLineItemCollection
70+
have been renamed to ProductVariantImportDraft, LineItemImportDraft and LineItemImportDraftCollection.
71+
72+
([018c7493](https://github.com/sphereio/sphere-php-sdk/commit/018c7493))
73+
* CartDiscountCodeReference renamed to DiscountCodeInfo
74+
75+
To streamline the naming schemes between the SDKs CartDiscountCodeReference has been renamed to DiscountCodeInfo
76+
77+
([db14db07](https://github.com/sphereio/sphere-php-sdk/commit/db14db07))
78+
* DeleteById requests renamed to Delete requests
79+
80+
To streamline the naming schemes between the SDKs delete requests have been renamed. E.g.:
81+
82+
Before:
83+
84+
```
85+
$request = ProductDeleteByIdRequest::ofIdAndVersion('<id>', <version>);
86+
```
87+
88+
After:
89+
90+
```
91+
$request = ProductDeleteRequest::ofIdAndVersion('<id>', <version>);
92+
```
93+
94+
([896e95a9](https://github.com/sphereio/sphere-php-sdk/commit/896e95a9))
95+
* FetchBy requests renamed to ByGetRequest
96+
97+
To streamline the naming schemes between the SDKs FetchBy requests have been renamed to ByGet requests. E.g.:
98+
99+
Before:
100+
101+
```
102+
$request = ProductFetchByIdRequest::ofId('<id>');
103+
```
104+
105+
After:
106+
107+
```
108+
$request = ProductByIdGetRequest::ofId('<id>');
109+
```
110+
111+
([d601dcfc](https://github.com/sphereio/sphere-php-sdk/commit/d601dcfc))
112+
* Document has been renamed to Resource
113+
114+
To streamline the naming schemes between the SDKs Document has been renamed to Resource. Type checks have to be adjusted
115+
116+
Before:
117+
118+
```
119+
if ($object instanceof \Sphere\Core\Model\Common\Document)
120+
```
121+
122+
After:
123+
124+
```
125+
if ($object instanceof \Sphere\Core\Model\Common\Resource)
126+
```
127+
128+
([5704fa3e](https://github.com/sphereio/sphere-php-sdk/commit/5704fa3e))
129+
* ProductSearchEndpoint has been renamed
130+
131+
Before:
132+
133+
```
134+
$endpoint = ProductSearchEndpoint::endpoint();
135+
```
136+
137+
After:
138+
139+
```
140+
$endpoint = ProductProjectionEndpoint::endpoint();
141+
```
142+
143+
closes [#103](https://github.com/sphereio/sphere-php-sdk/issues/103)
144+
145+
([e1b6989f](https://github.com/sphereio/sphere-php-sdk/commit/e1b6989f))
146+
* ProductsSearchRequest has been renamed
147+
148+
Before:
149+
150+
```
151+
$request = ProductsSearchRequest::of();
152+
```
153+
154+
After:
155+
156+
```
157+
$request = ProductProjectionSearchRequest::of();
158+
```
159+
160+
closes [#103](https://github.com/sphereio/sphere-php-sdk/issues/103)
161+
162+
([bd1bf7b1](https://github.com/sphereio/sphere-php-sdk/commit/bd1bf7b1))
163+
* config object fromArray method is declared static
164+
165+
Before:
166+
167+
```
168+
$config = new Config();
169+
$config->fromArray($configArray);
170+
```
171+
172+
After:
173+
174+
```
175+
$config = Config::fromArray($configArray);
176+
```
177+
178+
closes [#101](https://github.com/sphereio/sphere-php-sdk/issues/101)
179+
180+
([1a0c350f](https://github.com/sphereio/sphere-php-sdk/commit/1a0c350f))
181+
* ext-intl is now mandatory
182+
183+
([2afea8ad](https://github.com/sphereio/sphere-php-sdk/commit/2afea8ad))
184+
* getters return null if value is not set
185+
186+
To have a more reliable return values the implied instantiation of empty objects has been removed. This means before using a value is must be set explicit. Example for collections
187+
188+
Before:
189+
190+
```
191+
$obj = ProductTypeDraft::ofNameAndDescription('test', 'test');
192+
$obj->getAttributes()->add(AttributeDefinition::of()->setName('test'));
193+
```
194+
195+
After:
196+
197+
```
198+
$obj = ProductTypeDraft::ofNameAndDescription('test', 'test');
199+
$obj->setAttributes(AttributeDefinitionCollection::of()->add(AttributeDefinition::of()->setName('test')));
200+
```
201+
202+
Closes [#113](https://github.com/sphereio/sphere-php-sdk/issues/113)
203+
204+
([8b138e7b](https://github.com/sphereio/sphere-php-sdk/commit/8b138e7b))
205+
* all http client exceptions are now wrapped inside the SphereException hierarchy
206+
207+
Before:
208+
209+
```
210+
try {
211+
$response = $client->execute($request)
212+
} catch(\GuzzleHttp\Exception\RequestException $e) {
213+
...
214+
}
215+
```
216+
217+
After:
218+
219+
```
220+
try {
221+
$response = $client->execute($request)
222+
} catch(\Sphere\Core\Error\SphereException $e) {
223+
...
224+
}
225+
```
226+
227+
([a169611b](https://github.com/sphereio/sphere-php-sdk/commit/a169611b))
228+
* rename client method future to executeAsync
229+
230+
To streamline the request executing methods the future method has been renamed. To migrate the code follow the example:
231+
232+
Before:
233+
234+
```
235+
$response = $client->future($request);
236+
```
237+
238+
After:
239+
240+
```
241+
$response = $client->executeAsync($request);
242+
```
243+
244+
([51da11fa](https://github.com/sphereio/sphere-php-sdk/commit/51da11fa))
245+
* changes the static "of" constructor to named constructors
246+
247+
The static constructor "of" for models and requests needs magic methods in the class header to provide proper IDE support. By using the library as a dependency the magic methods were not correctly used by the IDE. Also the reflection used inside the OfTrait is not the best solution. So now all models and requests should have one or more named constructors which can be properly read by most IDE, don't require reflection for instantiation and can create instances without parameters which is helpful for testing purposes.
248+
249+
* constructor of Models and Requests doesn't have required values anymore
250+
* static "of" constructor instantiates class with given context object. Use named constructors for instantiating models or requests with arguments
251+
252+
([d19a83c1](https://github.com/sphereio/sphere-php-sdk/commit/d19a83c1))
253+
254+
### 1.0.0-beta.2 (Milestone 3)
4255
Major refactoring of the http client handling. Sphere client uses now PSR http messages for internal request and response representation and ships with a guzzle5 and guzzle6 http client adapter which will be automatically used. It's also possible to register new http client adapters implementing Sphere\Core\Client\Adapter\AdapterInterface
5256

6257
* switch composer to caret operator
@@ -50,7 +301,7 @@ Major refactoring of the http client handling. Sphere client uses now PSR http m
50301
* fix multi facet and filter params
51302
* fix type of TaxRate
52303

53-
### 1.0.0 Milestone 2
304+
### 1.0.0-beta.1 (Milestone 2)
54305
* add unit tests for query, fetch and delete requests
55306
* add tests for order and product update actions
56307
* add customer, category and cart update action tests

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![SPHERE.IO icon](https://admin.sphere.io/assets/images/sphere_logo_rgb_long.png)
22
# SPHERE.IO PHP SDK
33

4-
> STATUS: technically robust beta version, but we do not yet guarantee API compatibility until the 1.0.0 release. Please take your time to thoroughly test the upcoming RC (Milestone 4) release.
4+
> STATUS: technically robust beta version, but we do not yet guarantee API compatibility until the 1.0.0 release. Please take your time to thoroughly test the upcoming RC (Milestone 4) release.
55
> See the [Milestone Plan](https://github.com/sphereio/sphere-php-sdk/milestones?direction=desc&sort=completeness&state=open) for details of what's planned in detail. We love feedback and [Issue reports](https://github.com/sphereio/sphere-php-sdk/issues?q=is%3Aopen+is%3Aissue+sort%3Acreated-asc)!
66
77
[![Build Status](https://img.shields.io/travis/sphereio/sphere-php-sdk/master.svg?style=flat-square)](https://travis-ci.org/sphereio/sphere-php-sdk) [![Scrutinizer](https://img.shields.io/scrutinizer/g/sphereio/sphere-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/sphereio/sphere-php-sdk/) [![Scrutinizer](https://img.shields.io/scrutinizer/coverage/g/sphereio/sphere-php-sdk.svg?style=flat-square)](https://scrutinizer-ci.com/g/sphereio/sphere-php-sdk/) [![Packagist](https://img.shields.io/packagist/v/sphere/php-sdk.svg?style=flat-square)](https://packagist.org/packages/sphere/php-sdk) [![Packagist](https://img.shields.io/packagist/dm/sphere/php-sdk.svg?style=flat-square)](https://packagist.org/packages/sphere/php-sdk)
@@ -11,9 +11,16 @@ It also manages the OAuth2 security, provides caches and an interface for concur
1111

1212
The SDK is licensed under the permissive [MIT License](LICENSE). Don't hesitate to [contribute](#contribute)!
1313

14-
## Install & Integrate the SDK into your Project
1514

16-
The SDK requires a PHP version of 5.4 or higher with the apc(u) PHP extension for its default cache. If you provide an own Cache interface, apc(u) is not necessary. The curl extension is recommended but not strictly necessary because the SDK is using the [Guzzle library](https://github.com/guzzle/guzzle) library, which falls back to PHP stream wrappers if curl is not available.
15+
## Using the SDK
16+
17+
The [PHP API documentation](http://sphereio.github.io/sphere-php-sdk/docs/master) provides all the details you need in a searchable form.
18+
19+
### Install & Integrate the SDK into your Project
20+
21+
The SDK requires a PHP version of 5.4 or higher with the apc(u) PHP extension for its default cache. If you provide an own Cache interface, apc(u) is not necessary.
22+
The curl extension is recommended but not strictly necessary because the SDK is using the [Guzzle library](https://github.com/guzzle/guzzle) library, which falls back to PHP stream wrappers if curl is not available.
23+
The intl extension is required to directly output Money objects as a String.
1724

1825
The recommended way to install the SDK is through [Composer](http://getcomposer.org).
1926

@@ -42,9 +49,7 @@ With composer just run `composer update sphere/php-sdk` to update to compatible
4249

4350
Please read the [Changelog](CHANGELOG.md) before updating in any case.
4451

45-
## Use the SDK
46-
47-
The [PHP API documentation](http://sphereio.github.io/sphere-php-sdk/docs/master) provides all the details you need in a searchable form.
52+
### Getting started
4853

4954
To get up and running, [create a free test project](http://admin.sphere.io) to get a SPHERE project with API credentials (Menu "Developers"->"API Clients").
5055

@@ -53,7 +58,7 @@ To get up and running, [create a free test project](http://admin.sphere.io) to g
5358

5459
require '../vendor/autoload.php';
5560

56-
use Sphere\Core\Request\Products\ProductsSearchRequest;
61+
use Sphere\Core\Request\Products\ProductProjectionSearchRequest;
5762
use Sphere\Core\Client;
5863

5964
$config = [
@@ -67,7 +72,7 @@ $config = [
6772
* execute the request and get the PHP Object
6873
* (the client can and should be re-used)
6974
*/
70-
$search = ProductsSearchRequest::of()->addParam('text.en', 'red');
75+
$search = ProductProjectionSearchRequest::of()->addParam('text.en', 'red');
7176

7277
$client = new Client($config);
7378
$products = $client->execute($search)->toObject();
@@ -88,9 +93,8 @@ In real world, you will not put your API credentials directly into code but use
8893

8994
## Improve & Contribute to the SDK project
9095

91-
prepare your development environment (if necessary).
92-
93-
Mac OS X, assuming [Homebrew](http://brew.sh) is installed, do the following:
96+
### Mac OS X preparations:
97+
assuming [Homebrew](http://brew.sh) is installed, do the following:
9498

9599
```sh
96100
xcode-select --install
@@ -108,7 +112,18 @@ echo "date.timezone='Europe/Berlin'" >> /usr/local/etc/php/5.5/conf.d/60-user.in
108112
php composer.phar update
109113
```
110114

111-
Linux users install php 5.4+, apc(u), xdebug and ant according to their distro's package system.
115+
### Linux preparations :
116+
* install php 5.4+, apc(u), xdebug and ant according to their distro's package system.
117+
* make sure the curl, intl, mbstring, apcu and openssl extensions are activated in php.ini
118+
119+
### Windows preparations:
120+
* [install php](http://windows.php.net/download/) 5.4+, i.e. extract ZIP and make add php.exe location to your PATH. Use WAMP etc. if you like, but plain PHP commandline is all you really need (you can test example code in the built-in webserver).
121+
* enable the curl, intl, mbstring and openssl extenstions in php.ini
122+
* [install apcu](http://robert-rusu.blogspot.de/2014/06/install-apcu-on-windows.html) OR a redis extension and server
123+
* make a working ant available in the PATH
124+
* and [install composer](https://getcomposer.org/doc/00-intro.md#installation-windows).
125+
126+
### Start working:
112127

113128
Clone the develop branch of the repository (we're using the [gitflow](http://nvie.com/posts/a-successful-git-branching-model/) branching model, so master is for releases only):
114129

@@ -144,7 +159,7 @@ php -S localhost:8000 -t docroot
144159

145160
Now navigate to [http://localhost:8000](http://localhost:8000) in your browser.
146161

147-
### phpStorm
162+
### phpStorm configuration
148163

149164
To enable code style checks directly in phpStorm you have to configure the path to the phpcs at Preferences > Languages & Frameworks > PHP > Code Sniffer.
150165
Now you can enable at Preferences > Editor > Inspections > PHP the "PHP code sniffer validation" with PSR-2 standard. Change the severity if needed.

0 commit comments

Comments
 (0)