sammyjo20/pokeapi-sdk

Unofficial PHP SDK for Pokeapi

v2.0.0 2023-10-01 14:01 UTC

This package is auto-updated.

Last update: 2024-10-30 02:16:44 UTC


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
}