Skip to content

Commit 6ef4e73

Browse files
committed
doc: added base README
1 parent 8832bd6 commit 6ef4e73

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

README.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,71 @@
1-
# php-api-sdk
1+
# PHP API SDK
2+
3+
[![Latest Version](https://img.shields.io/github/release/programmatordev/php-api-sdk.svg?style=flat-square)](https://github.com/programmatordev/sportmonksfootball-php-api/releases)
4+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
5+
[![Tests](https://github.com/programmatordev/php-api-sdk/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/programmatordev/sportmonksfootball-php-api/actions/workflows/ci.yml?query=branch%3Amain)
6+
7+
A library for creating SDKs in PHP with support for:
8+
- [PSR-18 HTTP clients](https://www.php-fig.org/psr/psr-18);
9+
- [PSR-17 HTTP factories](https://www.php-fig.org/psr/psr-17);
10+
- [PSR-6 caches](https://www.php-fig.org/psr/psr-6);
11+
- [PSR-3 logs](https://www.php-fig.org/psr/psr-3);
12+
- Authentication;
13+
- Events;
14+
- ...and more.
15+
16+
## Requirements
17+
18+
- PHP 8.1 or higher.
19+
20+
## Installation
21+
22+
You can install the library via [Composer](https://getcomposer.org/):
23+
24+
```bash
25+
composer require programmatordev/php-api-sdk
26+
```
27+
28+
To use the library, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
29+
30+
```php
31+
require_once 'vendor/autoload.php';
32+
```
33+
34+
## Basic Usage
35+
36+
Simple usage looks like:
37+
38+
```php
39+
use ProgrammatorDev\Api\Api;
40+
use ProgrammatorDev\Api\Method;
41+
42+
class PokeApi extends Api
43+
{
44+
public function __construct()
45+
{
46+
parent::__construct();
47+
48+
$this->setBaseUrl('https://pokeapi.co/api/v2');
49+
}
50+
51+
public function getPokemon(int|string $idOrName): string
52+
{
53+
return $this->request(
54+
method: Method::GET,
55+
path: $this->buildPath('/pokemon/{idOrName}', [
56+
'idOrName' => $idOrName
57+
])
58+
);
59+
}
60+
}
61+
```
62+
63+
## Contributing
64+
65+
Any form of contribution to improve this library (including requests) will be welcome and appreciated.
66+
Make sure to open a pull request or issue.
67+
68+
## License
69+
70+
This project is licensed under the MIT license.
71+
Please see the [LICENSE](LICENSE) file distributed with this source code for further information regarding copyright and licensing.

src/Api.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private function configurePlugins(): void
9191
{
9292
// https://docs.php-http.org/en/latest/plugins/content-type.html
9393
$this->clientBuilder->addPlugin(new ContentTypePlugin(), 40);
94+
9495
// https://docs.php-http.org/en/latest/plugins/content-length.html
9596
$this->clientBuilder->addPlugin(new ContentLengthPlugin(), 32);
9697

0 commit comments

Comments
 (0)