Skip to content

Commit 0ecddea

Browse files
author
Harry Bragg
authored
modernise the development environment a bit (Guzzle 5) (#31)
* update guzzle-5 branch with docker * support php 5.4 * update README * add make help target * update makefile and .gitignore file * add composer.lock file * tidy up README
1 parent 5bd9f07 commit 0ecddea

22 files changed

+1875
-79
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
.pid
2-
.vagrant
3-
composer.lock
41
phpunit.xml
52
test/server/node_modules
63
vendor

.travis.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
language: php
22

3-
sudo: false
3+
dist: trusty
44

5-
php:
5+
cache:
6+
directories:
7+
- $HOME/.composer/cache/files
8+
- $HOME/.npm
9+
10+
php:
611
- 5.4
712
- 5.5
813
- 5.6
14+
- 7
15+
- 7.1
916
- hhvm
10-
- hhvm-nightly
17+
- nightly
1118

1219
matrix:
1320
allow_failures:
1421
- php: hhvm
15-
- php: hhvm-nightly
22+
- php: nightly
1623
fast_finish: true
1724

25+
before_install:
26+
- sudo apt-get update
27+
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
28+
1829
before_script:
19-
- ~/.nvm/nvm.sh install v0.10.32
20-
- ~/.nvm/nvm.sh run v0.10.32
21-
- make
30+
- make deps-js
31+
- travis_retry composer update --no-interaction
2232

2333
script:
24-
- make test
34+
- vendor/bin/phpcs -p --warning-severity=0 --ignore=test/server src/ test/
35+
- vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover --testsuite unit
36+
- make test-functional
37+
38+
after_script:
39+
- test -f ./tests/report/coverage.clover && (wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover ./tests/report/coverage.clover)

Makefile

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,52 @@
1-
NJS := `which node`
2-
PWD := `pwd`
3-
PID := $(PWD)/.pid
1+
.PHONY: deps deps-js deps-php help
2+
.PHONY: lint test test-unit test-functional test-coverage test-coverage-clover
3+
.PHONY: server-start server-stop
44

5-
.PHONY: cs test
65

7-
all: deps
6+
deps: ## Install all dependencies
7+
deps: deps-php deps-js
88

9-
cs:
10-
@vendor/bin/php-cs-fixer fix src
9+
deps-js: ## Install javascript dependencies
10+
@docker-compose run --rm node yarn install
1111

12-
deps: deps-php deps-js
12+
deps-php: ## Install php dependencies
13+
@docker-compose run --rm composer install --prefer-dist
1314

14-
deps-js:
15-
@cd test/server && npm install
1615

17-
deps-php:
18-
@composer install
16+
server-start: ## Start the test server
17+
@docker-compose up -d node
1918

20-
server-start:
21-
@start-stop-daemon -S -b -m -o -p $(PID) -d $(PWD)/test/server -x $(NJS) -- index.js
19+
server-stop: ## Stop the test server
20+
@docker-compose stop node
2221

23-
server-stop:
24-
@start-stop-daemon -K -p $(PID)
2522

23+
lint: ## Run phpcs against the code.
24+
@docker-compose run --rm test vendor/bin/phpcs -p --warning-severity=0 --ignore=test/server src/ test/
25+
26+
test: ## Run all the tests
2627
test: test-unit test-functional
2728

29+
test-functional: ## Test the functionality
2830
test-functional: server-start
29-
@vendor/bin/phpunit --testsuite functional
30-
@$(MAKE) server-stop
31+
@docker-compose run --rm test vendor/bin/phpunit --testsuite functional
32+
@${MAKE} server-stop
33+
34+
test-unit: ## Test the units
35+
@docker-compose run --rm test vendor/bin/phpunit --testsuite unit
36+
37+
test-coverage: ## Run all tests and output coverage to the console.
38+
test-coverage: server-start
39+
@docker-compose run --rm test phpdbg7 -qrr vendor/bin/phpunit --coverage-text
40+
@${MAKE} server-stop
41+
42+
test-coverage-clover: ## Run all tests and output clover coverage to file.
43+
test-coverage-clover: server-start
44+
@docker-compose run --rm test phpdbg7 -qrr vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover
45+
@${MAKE} server-stop
46+
3147

32-
test-unit:
33-
@vendor/bin/phpunit --testsuite unit
48+
help: ## Show this help message.
49+
@echo "usage: make [target] ..."
50+
@echo ""
51+
@echo "targets:"
52+
@egrep '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#'

README.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
11
# Guzzle JSON-RPC
22

33
[![Master branch build status][ico-build]][travis]
4+
[![Coverage Status][ico-coverage]][coverage]
5+
[![Quality Score][ico-quality]][quality]
46
[![Published version][ico-package]][package]
57
[![PHP ~5.4][ico-engine]][lang]
68
[![MIT Licensed][ico-license]][license]
79

810
This library implements [JSON-RPC 2.0][jsonrpc] for the Guzzle HTTP client. We
911
try to support all commonly used versions of Guzzle including:
10-
- [GuzzleHTTP 5][guzzle] on [`master`][branch-master] branch, `>= 2.1` releases
11-
- [GuzzleHTTP 4][guzzle] on [`guzzle-4`][branch-4] branch, `2.0.x` releases
12-
- [Guzzle 3][guzzle-3] on [`guzzle-3`][branch-3] branch, `1.x` releases
12+
13+
- [GuzzleHTTP 6][guzzle] on [`master`][branch-master] branch, `^3.0` releases
14+
- [GuzzleHTTP 5][guzzle] on [`guzzle-5`][branch-5] branch, `^2.1` releases
15+
- [GuzzleHTTP 4][guzzle] on [`guzzle-4`][branch-4] branch, `2.0.*` releases
16+
- [Guzzle 3][guzzle-3] on [`guzzle-3`][branch-3] branch, `^1.0` releases
1317

1418
It can be installed in whichever way you prefer, but we recommend [Composer][package].
19+
1520
```json
1621
{
1722
"require": {
18-
"graze/guzzle-jsonrpc": "~2.1"
23+
"graze/guzzle-jsonrpc": "^2.1"
1924
}
2025
}
2126
```
2227

28+
```shell
29+
~ $ composer require graze/guzzle-jsonrpc:^2.1
30+
```
31+
2332
## Documentation
33+
2434
```php
2535
<?php
2636
use Graze\GuzzleHttp\JsonRpc\Client;
@@ -43,10 +53,12 @@ $request->sendAll([
4353
```
4454

4555
### Throw exception on RPC error
56+
4657
You can throw an exception if you receive an RPC error response by attaching a
4758
subscriber to either the client or the request. You probably won't want to do so
4859
with batch requests as the exception will only include the first bad response in
4960
your batch.
61+
5062
```php
5163
<?php
5264
use Graze\GuzzleHttp\JsonRpc\Client;
@@ -68,40 +80,43 @@ try {
6880
}
6981
```
7082

71-
## Contributing
83+
### Contributing
84+
7285
We accept contributions to the source via Pull Request,
7386
but passing unit tests must be included before it will be considered for merge.
74-
```bash
75-
$ composer install
76-
$ make test
77-
```
7887

79-
If you have [Vagrant][vagrant] installed, you can build our dev environment to
80-
assist development. The repository will be mounted in `/srv`.
8188
```bash
82-
$ vagrant up
83-
$ vagrant ssh
84-
$ cd /srv
89+
~ $ make deps
90+
~ $ make lint test
8591
```
8692

8793
### License
94+
8895
The content of this library is released under the **MIT License** by
89-
**Nature Delivered Ltd**.<br/> You can find a copy of this license at
90-
http://www.opensource.org/licenses/mit or in [`LICENSE`][license]
96+
**Nature Delivered Ltd**.
97+
98+
You can find a copy of this license at
99+
[MIT][mit] or in [`LICENSE`][license]
91100

92101
<!-- Links -->
102+
[mit]: http://www.opensource.org/licenses/mit
93103
[travis]: https://travis-ci.org/graze/guzzle-jsonrpc
94104
[lang]: http://php.net
95105
[package]: https://packagist.org/packages/graze/guzzle-jsonrpc
106+
[coverage]: https://scrutinizer-ci.com/g/graze/guzzle-jsonrpc/guzzle-5/code-structure
107+
[quality]: https://scrutinizer-ci.com/g/graze/guzzle-jsonrpc/guzzle-5
96108
[ico-license]: http://img.shields.io/packagist/l/graze/guzzle-jsonrpc.svg?style=flat
97109
[ico-package]: http://img.shields.io/packagist/v/graze/guzzle-jsonrpc.svg?style=flat
98-
[ico-build]: http://img.shields.io/travis/graze/guzzle-jsonrpc/master.svg?style=flat
110+
[ico-build]: http://img.shields.io/travis/graze/guzzle-jsonrpc/guzzle-5.svg?style=flat
99111
[ico-engine]: http://img.shields.io/badge/php-~5.4-8892BF.svg?style=flat
112+
[ico-coverage]: https://img.shields.io/scrutinizer/coverage/g/graze/guzzle-jsonrpc/guzzle-5.svg?style=flat
113+
[ico-quality]: https://img.shields.io/scrutinizer/g/graze/guzzle-jsonrpc/guzzle-5.svg?style=flat
100114
[vagrant]: http://vagrantup.com
101115
[jsonrpc]: http://jsonrpc.org/specification
102116
[guzzle]: https://github.com/guzzle/guzzle
103117
[guzzle-3]: https://github.com/guzzle/guzzle3
104118
[branch-3]: https://github.com/graze/guzzle-jsonrpc/tree/guzzle-3
105119
[branch-4]: https://github.com/graze/guzzle-jsonrpc/tree/guzzle-4
120+
[branch-5]: https://github.com/graze/guzzle-jsonrpc/tree/guzzle-5
106121
[branch-master]: https://github.com/graze/guzzle-jsonrpc
107122
[license]: LICENSE

Vagrantfile

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

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
}
2323
},
2424
"require": {
25-
"php": ">=5.4",
25+
"php": ">=5.4|^7.0",
2626
"guzzlehttp/guzzle": "~5.0"
2727
},
2828
"require-dev": {
2929
"adlawson/timezone": "~1.0",
30-
"fabpot/php-cs-fixer": "~0.5",
30+
"squizlabs/php_codesniffer": "^2.9",
3131
"mockery/mockery": "~0.9",
32-
"phpunit/phpunit": "~4.3"
32+
"phpunit/phpunit": "~4.3",
33+
"graze/standards": "^1.0"
3334
}
3435
}

0 commit comments

Comments
 (0)