Skip to content

Commit 734b2c9

Browse files
Merge pull request #3 from basekit/php_8_upgrade
Upgrade guzzle client to V7 for PHP 8 compatibility
2 parents 8c1ed50 + de3ebc1 commit 734b2c9

File tree

14 files changed

+2846
-526
lines changed

14 files changed

+2846
-526
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint and Test
2+
run-name: ${{ github.actor }} is linting and testing 🚀
3+
4+
on: [push]
5+
6+
jobs:
7+
Lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check out repository code
11+
uses: actions/checkout@v3
12+
- name: 💅 Lint
13+
run: |
14+
make lint
15+
Test:
16+
strategy:
17+
matrix:
18+
php-versions: ['8.0', '8.1', '8.2']
19+
os: [ubuntu-latest, macos-latest]
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- name: Check out repository code
23+
uses: actions/checkout@v3
24+
- name: Set up PHP ${{ matrix.php-versions }}
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php-versions }}
28+
- name: 🧪 Test
29+
run: |
30+
make test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
vendor
22
tmp
3+
4+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
build: lint test
22

33
lint: vendor
4-
./vendor/bin/phpcs --standard=PSR2 src/
5-
./vendor/bin/phpcs --standard=PSR2 tests/
4+
./vendor/bin/phpcs --standard=PSR12 src/
5+
./vendor/bin/phpcs --standard=PSR12 tests/
66

77
test: vendor
88
./vendor/bin/phpunit

README.md

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
BaseKit REST API Client
2-
=======================
1+
# BaseKit REST API Client
32

4-
[![Build Status](https://secure.travis-ci.org/basekit/php-api-client.png)](http://travis-ci.org/basekit/php-api-client)
5-
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/basekit/php-api-client/badges/quality-score.png?s=1ebfb26b984131090693ffca1ba26ede5354a037)](https://scrutinizer-ci.com/g/basekit/php-api-client/)
3+
A PHP client for [BaseKit](http://basekit.com/)'s REST API. This client will provide documentation of the services available from the BaseKit API, describing URIs, HTTP methods and input parameters.
64

7-
A PHP client for [BaseKit]'s REST API. This client will provide documentation of
8-
the services available from the BaseKit API, describing URIs, HTTP methods and
9-
input parameters.
5+
## Installation
106

11-
Installation
12-
------------
7+
The recommended way of including this package in your project is by using Composer. Add it to the `require` section of your project's `composer.json`.
138

14-
The recommended way of including this package in your project is by using
15-
Composer. Add it to the `require` section of your project's `composer.json`.
16-
17-
"basekit/php-api-client": "1.2.1"
9+
```bash
10+
composer require basekit/php-api-client
11+
```
1812

19-
Usage
20-
-----
13+
## Usage
2114

2215
```php
23-
<?php
24-
25-
require 'vendor/autoload.php';
26-
use BaseKit\Api\Client;
27-
28-
$client = Client::factory(
29-
array(
30-
'base_url' => 'http://api.example.org',
31-
'consumer_key' => '1234567890',
32-
'consumer_secret' => 'qwertyuiop',
33-
'token' => 'asdfghjkl',
34-
'token_secret' => 'zxcvbnm',
35-
)
16+
use BaseKit\Api\AuthType;
17+
use BaseKit\Api\ClientFactory;
18+
19+
$client = ClientFactory::create(
20+
[
21+
'base_uri' => 'http://api.testing.com',
22+
'username' => 'foo',
23+
'password' => 'bar',
24+
],
25+
AuthType::BASIC, // defaults to basic auth
3626
);
3727

3828
$createSite = $client->getCommand(
3929
'CreateSite',
40-
array(
30+
[
4131
'accountHolderRef' => 123,
42-
'brandRef' => 456,
32+
'brandRef' => 789,
4333
'domain' => 'test.example.org',
44-
)
34+
]
4535
);
46-
$response = $createSite->execute();
47-
print_r($response);
36+
37+
$client->execute($createSite);
4838
```
4939

50-
Contributing
51-
------------
40+
## Testing
5241

53-
This project adheres to the [PSR2] coding style guide. Checking your
54-
contribution's correctness is easy.
42+
Feed an optional `handler` into the config of `clientFactory` to control the responses from the http client.
5543

56-
```bash
57-
$ make lint
58-
```
44+
```php
45+
use BaseKit\Api\ClientFactory;
46+
use GuzzleHttp\HandlerStack;
47+
use GuzzleHttp\Handler\MockHandler;
48+
use GuzzleHttp\Psr7\Response;
49+
50+
$client = ClientFactory::create([
51+
'base_uri' => 'https://api.testing.com',
52+
'username' => 'foo',
53+
'password' => 'bar',
54+
'handler' => HandlerStack::create(
55+
new MockHandler([
56+
new Response(404, [], 'Hello, World! This is a test response.'),
57+
])
58+
) ,
59+
]);
5960

60-
There's a very small unit test suite, using [PHPUnit]. Making sure you haven't
61-
broken any tests is easy too.
61+
$createSite = $client->getCommand(
62+
'CreateSite',
63+
[
64+
'accountHolderRef' => 123,
65+
'brandRef' => 789,
66+
'domain' => 'test.example.org',
67+
]
68+
);
6269

63-
```bash
64-
$ make test
70+
$client->execute($createSite); // Throws a 404 CommandClientException
6571
```
6672

67-
License
68-
-------
69-
70-
This software is released under the [MIT License].
73+
## License
7174

72-
[BaseKit]: http://basekit.com/
73-
[PHPUnit]: http://phpunit.de/
74-
[PSR2]: http://www.php-fig.org/psr/psr-2/
75-
[MIT License]: http://www.opensource.org/licenses/MIT
75+
This software is released under the [MIT License](http://www.opensource.org/licenses/MIT).

composer.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
2-
32
"name": "basekit/php-api-client",
43
"description": "BaseKit PHP API client.",
5-
64
"authors": [
75
{
86
"name": "Simon Best",
@@ -13,26 +11,25 @@
1311
"email": "adrian.slade@basekit.com"
1412
}
1513
],
16-
1714
"minimum-stability": "dev",
18-
1915
"autoload": {
2016
"psr-4": {
2117
"BaseKit\\Api\\": "src/"
2218
}
2319
},
24-
2520
"require": {
26-
"guzzle/guzzle": ">=v3.7.4"
21+
"guzzlehttp/guzzle": "7.*",
22+
"guzzlehttp/guzzle-services": "1.3.*",
23+
"guzzlehttp/command": "1.2.*",
24+
"guzzlehttp/oauth-subscriber": "0.6.*"
2725
},
28-
2926
"require-dev": {
3027
"squizlabs/php_codesniffer": "3.*",
31-
"phpunit/phpunit": "3.7.*@dev"
28+
"phpunit/phpunit": "^9.5"
3229
},
3330
"config": {
3431
"platform": {
35-
"php": "5.6"
32+
"php": "8.0.0"
3633
}
3734
}
3835
}

0 commit comments

Comments
 (0)