Skip to content

Commit

Permalink
Init project
Browse files Browse the repository at this point in the history
  • Loading branch information
codenix-sv committed Mar 18, 2020
1 parent fa5bae9 commit d7f73ee
Show file tree
Hide file tree
Showing 10 changed files with 731 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vendor
composer.lock
build
phpunit.xml
.phpunit.result.cache
5 changes: 5 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
imports:
- php

tools:
external_code_coverage: true
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
language: php

php:
- '7.2'
- '7.3'
- '7.4'

sudo: false

cache:
directories:
- $HOME/.composer/cache

install:
- travis_retry composer self-update && composer --version
- travis_retry composer update --dev --prefer-dist --no-interaction

before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

script:
- composer validate --strict
- vendor/bin/phpunit

after_script:
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml

notifications:
email:
recipients:
- [email protected]
on_success: never
on_failure: always
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# PHP API Client

[![Build Status](https://travis-ci.org/codenix-sv/api-client.svg?branch=master)](https://travis-ci.org/codenix-sv/api-client)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/codenix-sv/api-client/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/codenix-sv/api-client/?branch=master)
[![License: MIT](https://img.shields.io/github/license/codenix-sv/api-client)](https://github.com/codenix-sv/api-client/blob/master/LICENSE)


A simple API client, written with PHP that's easy to use.

## Requirements

* PHP >= 7.2
* A [HTTP client](https://packagist.org/providers/php-http/client-implementation)
* A [PSR-7 implementation](https://packagist.org/providers/psr/http-message-implementation)

## Installation

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```bash
$ composer require codenix-sv/api-client
```
or add

```json
"codenix-sv/api-client": "^1.0"
```

to the require section of your application's `composer.json` file.

Make sure you have installed a PSR-18 HTTP Client and PSR-7 message implementation before you install this package. For example:

```bash
$ composer require php-http/curl-client nyholm/psr7
```

## Examples

*Send GET request*

```php
use Codenixsv\ApiClient\BaseClient;

$client = new BaseClient();
$response = $client->get('https://httpbin.org/get');
```

*Send POST request*

```php
use Codenixsv\ApiClient\BaseClient;

$client = new BaseClient();
$response = $client->post('https://httpbin.org/post', 'foo=bar');
```

## License

`codenix-sv/api-client` is released under the MIT License. See the bundled [LICENSE](./LICENSE) for details.
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "codenix-sv/api-client",
"type": "library",
"description": "PHP API client",
"homepage": "https://github.com/codenix-sv/api-client",
"keywords": ["client", "api", "php", "api-client", "psr-7", "psr-18"],
"license": "MIT",
"support": {
"issues": "https://github.com/codenix-sv/api-client/issues?state=open",
"source": "https://github.com/codenix-sv/api-client"
},
"authors": [
{
"name": "Volodymyr Svyryd",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"php": ">=7.2",
"psr/http-message": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-client": "^1.0",
"psr/cache": "^1.0",
"php-http/httplug": "^2.0",
"php-http/discovery": "^1.7",
"php-http/client-common": "^2.0",
"php-http/message": "^1.8"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"php-http/mock-client": "^1.3",
"php-http/guzzle6-adapter": "^2.0",
"nyholm/psr7": "^1.2"
},
"autoload": {
"psr-4": { "Codenixsv\\ApiClient\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Codenixsv\\ApiClient\\Tests\\": "tests/"}
},
"prefer-stable": true
}
28 changes: 28 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
Loading

0 comments on commit d7f73ee

Please sign in to comment.