|
1 | | -# php-api-sdk |
| 1 | +# PHP API SDK |
| 2 | + |
| 3 | +[](https://github.com/programmatordev/sportmonksfootball-php-api/releases) |
| 4 | +[](LICENSE) |
| 5 | +[](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. |
0 commit comments