Skip to content

Commit

Permalink
modernise the development environment a bit (Guzzle 5) (#31)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Harry Bragg authored Dec 13, 2017
1 parent 5bd9f07 commit 0ecddea
Show file tree
Hide file tree
Showing 22 changed files with 1,875 additions and 79 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.pid
.vagrant
composer.lock
phpunit.xml
test/server/node_modules
vendor
31 changes: 23 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
language: php

sudo: false
dist: trusty

php:
cache:
directories:
- $HOME/.composer/cache/files
- $HOME/.npm

php:
- 5.4
- 5.5
- 5.6
- 7
- 7.1
- hhvm
- hhvm-nightly
- nightly

matrix:
allow_failures:
- php: hhvm
- php: hhvm-nightly
- php: nightly
fast_finish: true

before_install:
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce

before_script:
- ~/.nvm/nvm.sh install v0.10.32
- ~/.nvm/nvm.sh run v0.10.32
- make
- make deps-js
- travis_retry composer update --no-interaction

script:
- make test
- vendor/bin/phpcs -p --warning-severity=0 --ignore=test/server src/ test/
- vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover --testsuite unit
- make test-functional

after_script:
- 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)
59 changes: 39 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
NJS := `which node`
PWD := `pwd`
PID := $(PWD)/.pid
.PHONY: deps deps-js deps-php help
.PHONY: lint test test-unit test-functional test-coverage test-coverage-clover
.PHONY: server-start server-stop

.PHONY: cs test

all: deps
deps: ## Install all dependencies
deps: deps-php deps-js

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

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

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

deps-php:
@composer install
server-start: ## Start the test server
@docker-compose up -d node

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

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

lint: ## Run phpcs against the code.
@docker-compose run --rm test vendor/bin/phpcs -p --warning-severity=0 --ignore=test/server src/ test/

test: ## Run all the tests
test: test-unit test-functional

test-functional: ## Test the functionality
test-functional: server-start
@vendor/bin/phpunit --testsuite functional
@$(MAKE) server-stop
@docker-compose run --rm test vendor/bin/phpunit --testsuite functional
@${MAKE} server-stop

test-unit: ## Test the units
@docker-compose run --rm test vendor/bin/phpunit --testsuite unit

test-coverage: ## Run all tests and output coverage to the console.
test-coverage: server-start
@docker-compose run --rm test phpdbg7 -qrr vendor/bin/phpunit --coverage-text
@${MAKE} server-stop

test-coverage-clover: ## Run all tests and output clover coverage to file.
test-coverage-clover: server-start
@docker-compose run --rm test phpdbg7 -qrr vendor/bin/phpunit --coverage-clover=./tests/report/coverage.clover
@${MAKE} server-stop


test-unit:
@vendor/bin/phpunit --testsuite unit
help: ## Show this help message.
@echo "usage: make [target] ..."
@echo ""
@echo "targets:"
@egrep '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#'
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
# Guzzle JSON-RPC

[![Master branch build status][ico-build]][travis]
[![Coverage Status][ico-coverage]][coverage]
[![Quality Score][ico-quality]][quality]
[![Published version][ico-package]][package]
[![PHP ~5.4][ico-engine]][lang]
[![MIT Licensed][ico-license]][license]

This library implements [JSON-RPC 2.0][jsonrpc] for the Guzzle HTTP client. We
try to support all commonly used versions of Guzzle including:
- [GuzzleHTTP 5][guzzle] on [`master`][branch-master] branch, `>= 2.1` releases
- [GuzzleHTTP 4][guzzle] on [`guzzle-4`][branch-4] branch, `2.0.x` releases
- [Guzzle 3][guzzle-3] on [`guzzle-3`][branch-3] branch, `1.x` releases

- [GuzzleHTTP 6][guzzle] on [`master`][branch-master] branch, `^3.0` releases
- [GuzzleHTTP 5][guzzle] on [`guzzle-5`][branch-5] branch, `^2.1` releases
- [GuzzleHTTP 4][guzzle] on [`guzzle-4`][branch-4] branch, `2.0.*` releases
- [Guzzle 3][guzzle-3] on [`guzzle-3`][branch-3] branch, `^1.0` releases

It can be installed in whichever way you prefer, but we recommend [Composer][package].

```json
{
"require": {
"graze/guzzle-jsonrpc": "~2.1"
"graze/guzzle-jsonrpc": "^2.1"
}
}
```

```shell
~ $ composer require graze/guzzle-jsonrpc:^2.1
```

## Documentation

```php
<?php
use Graze\GuzzleHttp\JsonRpc\Client;
Expand All @@ -43,10 +53,12 @@ $request->sendAll([
```

### Throw exception on RPC error

You can throw an exception if you receive an RPC error response by attaching a
subscriber to either the client or the request. You probably won't want to do so
with batch requests as the exception will only include the first bad response in
your batch.

```php
<?php
use Graze\GuzzleHttp\JsonRpc\Client;
Expand All @@ -68,40 +80,43 @@ try {
}
```

## Contributing
### Contributing

We accept contributions to the source via Pull Request,
but passing unit tests must be included before it will be considered for merge.
```bash
$ composer install
$ make test
```

If you have [Vagrant][vagrant] installed, you can build our dev environment to
assist development. The repository will be mounted in `/srv`.
```bash
$ vagrant up
$ vagrant ssh
$ cd /srv
~ $ make deps
~ $ make lint test
```

### License

The content of this library is released under the **MIT License** by
**Nature Delivered Ltd**.<br/> You can find a copy of this license at
http://www.opensource.org/licenses/mit or in [`LICENSE`][license]
**Nature Delivered Ltd**.

You can find a copy of this license at
[MIT][mit] or in [`LICENSE`][license]

<!-- Links -->
[mit]: http://www.opensource.org/licenses/mit
[travis]: https://travis-ci.org/graze/guzzle-jsonrpc
[lang]: http://php.net
[package]: https://packagist.org/packages/graze/guzzle-jsonrpc
[coverage]: https://scrutinizer-ci.com/g/graze/guzzle-jsonrpc/guzzle-5/code-structure
[quality]: https://scrutinizer-ci.com/g/graze/guzzle-jsonrpc/guzzle-5
[ico-license]: http://img.shields.io/packagist/l/graze/guzzle-jsonrpc.svg?style=flat
[ico-package]: http://img.shields.io/packagist/v/graze/guzzle-jsonrpc.svg?style=flat
[ico-build]: http://img.shields.io/travis/graze/guzzle-jsonrpc/master.svg?style=flat
[ico-build]: http://img.shields.io/travis/graze/guzzle-jsonrpc/guzzle-5.svg?style=flat
[ico-engine]: http://img.shields.io/badge/php-~5.4-8892BF.svg?style=flat
[ico-coverage]: https://img.shields.io/scrutinizer/coverage/g/graze/guzzle-jsonrpc/guzzle-5.svg?style=flat
[ico-quality]: https://img.shields.io/scrutinizer/g/graze/guzzle-jsonrpc/guzzle-5.svg?style=flat
[vagrant]: http://vagrantup.com
[jsonrpc]: http://jsonrpc.org/specification
[guzzle]: https://github.com/guzzle/guzzle
[guzzle-3]: https://github.com/guzzle/guzzle3
[branch-3]: https://github.com/graze/guzzle-jsonrpc/tree/guzzle-3
[branch-4]: https://github.com/graze/guzzle-jsonrpc/tree/guzzle-4
[branch-5]: https://github.com/graze/guzzle-jsonrpc/tree/guzzle-5
[branch-master]: https://github.com/graze/guzzle-jsonrpc
[license]: LICENSE
20 changes: 0 additions & 20 deletions Vagrantfile

This file was deleted.

7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
}
},
"require": {
"php": ">=5.4",
"php": ">=5.4|^7.0",
"guzzlehttp/guzzle": "~5.0"
},
"require-dev": {
"adlawson/timezone": "~1.0",
"fabpot/php-cs-fixer": "~0.5",
"squizlabs/php_codesniffer": "^2.9",
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.3"
"phpunit/phpunit": "~4.3",
"graze/standards": "^1.0"
}
}
Loading

0 comments on commit 0ecddea

Please sign in to comment.