sammyjo20 / pokeapi-sdk
Unofficial PHP SDK for Pokeapi
v2.0.0
2023-10-01 14:01 UTC
Requires
- php: ^8.1
- saloonphp/pagination-plugin: ^2.0.0-beta.3
- saloonphp/saloon: ^3.0.0-beta.7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- pestphp/pest: ^1.22
- symfony/var-dumper: ^6.2
README
This is an example PHP SDK built with Saloon v3.
Available Requests
Pokeapi\Requests\GetAllPokemon
Pokeapi\Requests\GetAllItems
Installation
Use Composer to install this SDK
composer require sammyjo20/pokeapi-sdk
Usage
Simply call the send
method with the request class you would like to send. Once sent, a PokeapiResponse
is returned.
<?php use Pokeapi\Pokeapi; use Pokeapi\Requests\GetAllPokemon; $pokeapi = new Pokeapi(); $response = $pokeapi->send(new GetAllPokemon);
Paginated Results
You may prefer to retrieve all the results from the paginated requests by using the paginate
method on the SDK.
<?php use Pokeapi\Pokeapi; use Pokeapi\Requests\GetAllPokemon; $pokeapi = new Pokeapi(); $paginator = $pokeapi->paginate(new GetAllPokemon); foreach($paginator->items() as $item) { // Handle result }