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

Commit 1cc5662

Browse files
author
Jens Schulze
committed
Merge branch 'release/M3'
2 parents 516d5e5 + 6b3b504 commit 1cc5662

File tree

297 files changed

+6163
-1118
lines changed

Some content is hidden

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

297 files changed

+6163
-1118
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ cache.properties
66
apigen.phar
77
composer.phar
88
composer.lock
9-
docroot/myapp.ini
9+
myapp.ini
1010
local/

.scrutinizer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ tools:
1111
before_commands:
1212
- composer install --prefer-source -o
1313
build:
14+
environment:
15+
php: '5.5.25'
1416
dependencies:
1517
before:
1618
#Only 5.4 uses APC

.travis.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ matrix:
1111
- php: hhvm
1212
- php: nightly
1313

14+
services:
15+
- redis-server
16+
1417
cache:
1518
directories:
1619
- vendor
1720

1821
before_script:
22+
- composer config -g github-oauth.github.com $GITHUB_OAUTH_TOKEN
23+
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
1924
- 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"
2025
- sh -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ] ; then phpenv config-add ./tests/apc.ini; fi"
21-
- composer install --prefer-source -o
26+
- if [ $TRAVIS_PHP_VERSION == '5.4' ] ; then ./set_guzzle5.sh; fi
27+
- composer install -o
2228

2329
script:
2430
- ant phpcs-ci
2531
- phpunit --testsuite=unit
26-
- if [ $TRAVIS_PHP_VERSION == '5.4' ] ; then phpunit --testsuite=integration; fi
32+
- if [ $TRAVIS_PHP_VERSION == '5.5' ] ; then phpunit --testsuite=integration; fi
2733
- ant behat
2834

2935
after_success:
@@ -39,3 +45,7 @@ env:
3945
- secure: Q4zRyFxLw/7YlHG/iWzyR7V7Srm8LsQ3UgMshckUyqefhzhF19GefoPJdPdALyLVEYQMG3O/U1aebbyt8Puy5jWWKKiwFaQA+mMXzpBFcvhutgxByqBXdIysIhGU65No+WbiCKlpL2WPNtYvE1cMSjFfn7IX8ThGkBxhJQcha38=
4046
# SPHERE_PROJECT
4147
- secure: CPj46vCtmLaxGKXycJW+PmNXloXu5ruOV/Qg1mA6tU83oPjlxHVrqMOlb87ykf6U8X6XXAjMrgR0q3gBepPJg3HZmJyeOsVhwSU/jhfN7L1lR7BrQrPdLutvhuC6Fgj+b2Ubzh7PIt7pR6AYZyMCv5ofajW9aBcC5D556WJsSjE=
48+
notifications:
49+
hipchat:
50+
rooms:
51+
secure: VD5RvUZYVg1aokw8OeMhNfDPc39o2r4Jjq8s6U2QvMXzoiopHpj6+VYX1AHbhxMpBGmsgKfzbYQ6XfubJUeHq+FMzW3YEekwcyqXKCfWi5tLCE7Epb0dCySatztVTkqlXzXaAM6NhzdFxG6kQPiA9OcSvRPZmSwjuX4eYXRokRw=

README.md

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

4-
> WARNING: As of now, this is a pre-release partial implementation.
5-
> See the [Milestone Plan](https://github.com/sphereio/sphere-php-sdk/milestones?direction=desc&sort=completeness&state=open) for details of what's planned. We love feedback and [Issue reports](https://github.com/sphereio/sphere-php-sdk/issues?q=is%3Aopen+is%3Aissue+sort%3Acreated-asc)!
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.
5+
> 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)
88

9-
The PHP SDK allows developers to build applications on the SPHERE.IO REST API using PHP native interfaces, models and helpers instead of manually using the HTTP and JSON API. Users gain lots of IDE Auto-Completion and type checks on a literal API.
9+
The PHP SDK allows developers to build applications on the SPHERE.IO REST API using PHP native interfaces, models and helpers instead of manually using the HTTP and JSON API. You gain lots of IDE Auto-Completion, type checks on a literal API, Warnings, Object Mapping, i18n support etc..
1010
It also manages the OAuth2 security, provides caches and an interface for concurrent and asynchronous API calls.
1111

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

14-
## Install / Integrate into your Project
14+
## Install & Integrate the SDK into your Project
1515

1616
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.
1717

@@ -25,7 +25,7 @@ curl -sS https://getcomposer.org/installer | php
2525
Next, run the Composer command to install the latest version of the SDK:
2626

2727
```bash
28-
composer require sphere/php-sdk
28+
composer require sphere/php-sdk dev-master
2929
```
3030

3131
After installing, you need to require Composer's autoloader if that's not yet the case:
@@ -34,7 +34,7 @@ After installing, you need to require Composer's autoloader if that's not yet th
3434
require 'vendor/autoload.php';
3535
```
3636

37-
If you don't use Composer, just [download a zip archive](archive/master.zip) of the latest release, manually integrate it and configure your own autoloader.
37+
If you don't use Composer, just [download a zip archive](https://github.com/sphereio/sphere-php-sdk/archive/master.zip) of the latest release, manually integrate it and configure your own autoloader.
3838

3939
Until the 1.0.0 release M0, M1 etc. milestone releases can contain incompatible changes. From 1.0.0 on, the project will follow the [semantic versioning](http://semver.org) guidelines, i.e. everything but major version changes are backwards-compatible. This matches composer's default behavior.
4040

@@ -44,6 +44,8 @@ Please read the [Changelog](CHANGELOG.md) before updating in any case.
4444

4545
## Use the SDK
4646

47+
The [PHP API documentation](http://sphereio.github.io/sphere-php-sdk/docs/master) provides all the details you need in a searchable form.
48+
4749
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").
4850

4951
```php
@@ -54,22 +56,27 @@ require '../vendor/autoload.php';
5456
use Sphere\Core\Request\Products\ProductsSearchRequest;
5557
use Sphere\Core\Client;
5658

57-
header('Content-Type: text/html; charset=utf-8');
58-
5959
$config = [
6060
'client_id' => 'my client id',
6161
'client_secret' => 'my client secret',
6262
'project' => 'my project id'
6363
];
6464

6565
/**
66-
* create search request
66+
* create a search request and a client,
67+
* execute the request and get the PHP Object
68+
* (the client can and should be re-used)
6769
*/
6870
$search = ProductsSearchRequest::of()->addParam('text.en', 'red');
6971

7072
$client = new Client($config);
7173
$products = $client->execute($search)->toObject();
7274

75+
/**
76+
* show result (would be a view layer in real world)
77+
*/
78+
header('Content-Type: text/html; charset=utf-8');
79+
7380
foreach ($products as $product) {
7481
echo $product->getName()->en . '<br/>';
7582
}
@@ -79,9 +86,7 @@ foreach ($products as $product) {
7986

8087
In real world, you will not put your API credentials directly into code but use a config file or your framework's config or dependency injection system for that.
8188

82-
The [API documentation](http://sphereio.github.io/sphere-php-sdk/docs/master) provides all the details you need in a searchable form.
83-
84-
## Develop and Improve
89+
## Improve & Contribute to the SDK project
8590

8691
prepare your development environment (if necessary).
8792

@@ -93,6 +98,7 @@ brew tap homebrew/dupes
9398
brew tap homebrew/versions
9499
brew tap homebrew/homebrew-php
95100
brew install php55
101+
brew install php55-intl
96102
brew install php55-apcu
97103
brew install php55-xdebug
98104
brew install ant
@@ -144,7 +150,7 @@ To enable code style checks directly in phpStorm you have to configure the path
144150
Now you can enable at Preferences > Editor > Inspections > PHP the "PHP code sniffer validation" with PSR-2 standard. Change the severity if needed.
145151

146152

147-
## <a name="contribute"></a>Contribute
153+
### <a name="contribute"></a>Contribute
148154

149155
On bigger effort changes, please open a GitHub [issue](issues) and ask if you can help or get help with your idea. For typos and documentation improvements just make a pull request.
150156

composer.json

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
"license": "MIT",
44
"type": "project",
55
"description": "The Sphere.IO PHP SDK",
6+
"homepage": "https://github.com/sphereio/sphere-php-sdk",
7+
"support": {
8+
"email": "support@sphere.io",
9+
"forum": "http://support.sphere.io",
10+
"issues": "https://github.com/sphereio/sphere-php-sdk/issues",
11+
"docs": "http://sphereio.github.io/sphere-php-sdk/docs/master/"
12+
},
613
"autoload": {
714
"psr-4": { "Sphere\\Core\\": "src/" }
815
},
@@ -16,22 +23,24 @@
1623
},
1724
"require": {
1825
"php": ">=5.4",
19-
"psr/log": "~1.0",
20-
"guzzlehttp/guzzle": "~5.0",
21-
"guzzlehttp/log-subscriber": "~1.0",
22-
"pimple/pimple": "~3.0"
26+
"psr/log": "^1.0",
27+
"guzzlehttp/guzzle": "^5.0 || ^6.0",
28+
"guzzlehttp/psr7": "^1.0",
29+
"pimple/pimple": "^3.0"
2330
},
2431
"require-dev": {
25-
"phpunit/phpunit": "~4.0",
26-
"phpmd/phpmd": "~1.0",
27-
"squizlabs/php_codesniffer": "~1.0",
28-
"pdepend/pdepend": "~1.1",
29-
"phploc/phploc": "~2.0",
30-
"sebastian/phpcpd": "~1.4",
31-
"mayflower/php-codebrowser": "~1.0",
32-
"doctrine/cache": "~1.4",
33-
"monolog/monolog": "~1.12",
34-
"behat/behat": "~3.0",
32+
"guzzlehttp/guzzle": "^6.0",
33+
"phpunit/phpunit": "^4.0",
34+
"phpmd/phpmd": "^1.0",
35+
"squizlabs/php_codesniffer": "^1.0",
36+
"pdepend/pdepend": "^1.1",
37+
"phploc/phploc": "^2.0",
38+
"sebastian/phpcpd": "^1.4",
39+
"mayflower/php-codebrowser": "^1.0",
40+
"doctrine/cache": "^1.4",
41+
"monolog/monolog": "^1.12",
42+
"behat/behat": "^3.0",
43+
"phpspec/prophecy-phpunit": "^1.0",
3544
"phpunit/phpcov": "*"
3645
},
3746
"suggest": {

features/bootstrap/FeatureContext.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function thePathShouldBe($expectedPath)
8080
{
8181
$httpRequest = $this->request->httpRequest();
8282

83-
assertSame($expectedPath, $httpRequest->getPath());
83+
assertSame($expectedPath, (string)$httpRequest->getUri());
8484
}
8585

8686
/**
@@ -90,7 +90,7 @@ public function theRequestShouldBe(PyStringNode $result)
9090
{
9191
$expectedResult = (string)$result;
9292
$httpRequest = $this->request->httpRequest();
93-
$request = $httpRequest->getBody();
93+
$request = (string)$httpRequest->getBody();
9494

9595
assertJsonStringEqualsJsonString($expectedResult, $request);
9696
}
@@ -102,7 +102,7 @@ public function theMethodShouldBe($expectedMethod)
102102
{
103103
$httpRequest = $this->request->httpRequest();
104104

105-
assertSame(strtolower($expectedMethod), $httpRequest->getHttpMethod());
105+
assertSame(strtoupper($expectedMethod), $httpRequest->getMethod());
106106
}
107107

108108
protected function createRequestInstance($className, $params = [])
@@ -211,8 +211,13 @@ public function iWantToUpdateAContext($context)
211211
*/
212212
public function theContextFieldIsValueAsType($field, $value, $type)
213213
{
214-
$method = $type . 'val';
215-
$this->theContextFieldIsValue($field, $method($value));
214+
if ($type == 'bool') {
215+
$value = (bool)$value;
216+
} else {
217+
$method = $type . 'val';
218+
$value = $method($value);
219+
}
220+
$this->theContextFieldIsValue($field, $value);
216221
}
217222

218223
/**
@@ -654,4 +659,15 @@ public function queryByCustomersId($customerId)
654659
{
655660
$this->request->byCustomerId($customerId);
656661
}
662+
663+
/**
664+
* @Given i want to import a :context
665+
*/
666+
public function iWantToImportAContext($context)
667+
{
668+
$context = $this->getContext($context);
669+
$module = $this->getModuleName($context);
670+
$request = '\Sphere\Core\Request\\' . $module . '\\' . $context . 'ImportRequest';
671+
$this->createRequestInstance($request, [$this->getContextObject($context)]);
672+
}
657673
}

features/request/Cart/CartCreate.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Feature: I want to create a new cart
66

77
Scenario: create a anonymous cart
88
When i want to create a "cart"
9-
Then the path should be "carts"
9+
Then the path should be "/carts"
1010
And the method should be "POST"
1111
And the request should be
1212
"""

features/request/Cart/CartDelete.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ Feature: I want to delete a cart
22
Scenario: Delete cart
33
Given a "cart" is identified by "id" and "version"
44
And i want to delete a "Cart"
5-
Then the path should be "carts/id?version=version"
5+
Then the path should be "/carts/id?version=version"
66
And the method should be "DELETE"

features/request/Cart/CartQuery.feature

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@ Feature: I want to query carts
22
Scenario: Fetch a cart by id
33
Given a "cart" is identified by "id"
44
Given i want to fetch a "Cart"
5-
Then the path should be "carts/id"
5+
Then the path should be "/carts/id"
66
And the method should be "GET"
77

88
Scenario: Query carts
99
Given a "cart" is identified by "id"
1010
Given i want to fetch a "cart" by customerId
1111
And query by customers id "id"
12-
Then the path should be "carts?customerId=id"
12+
Then the path should be "/carts?customerId=id"
1313
And the method should be "GET"
1414

1515
Scenario: Query customers with filter applied
1616
Given i want to query "Carts"
1717
And filter them with criteria 'name="Peter"'
18-
Then the path should be "carts?where=name%3D%22Peter%22"
18+
Then the path should be "/carts?where=name%3D%22Peter%22"
1919
And the method should be "GET"
2020

2121
Scenario: Query customers with filter applied
2222
Given i want to query "Carts"
2323
And filter them with criteria 'name="Peter"'
24-
Then the path should be "carts?where=name%3D%22Peter%22"
24+
Then the path should be "/carts?where=name%3D%22Peter%22"
2525
And the method should be "GET"
2626

2727
Scenario: Query customers with limit
2828
Given i want to query "Carts"
2929
And limit the result to "10"
30-
Then the path should be "carts?limit=10"
30+
Then the path should be "/carts?limit=10"
3131
And the method should be "GET"
3232

3333
Scenario: Query customers with offset
3434
Given i want to query "Carts"
3535
And offset the result with "10"
36-
Then the path should be "carts?offset=10"
36+
Then the path should be "/carts?offset=10"
3737
And the method should be "GET"
3838

3939
Scenario: Query customers sorted
4040
Given i want to query "Carts"
4141
And sort them by "name"
42-
Then the path should be "carts?sort=name"
42+
Then the path should be "/carts?sort=name"
4343
And the method should be "GET"
4444

4545
Scenario: Query parameters should be sorted
4646
Given i want to query "Carts"
4747
And sort them by "name"
4848
And offset the result with "10"
49-
Then the path should be "carts?offset=10&sort=name"
49+
Then the path should be "/carts?offset=10&sort=name"
5050
And the method should be "GET"

0 commit comments

Comments
 (0)