PHP code example of communitydragon / phizz
1. Go to this page and download the library: Download communitydragon/phizz library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
communitydragon / phizz example snippets
use Phizz\Facades\Phizz;
use Phizz\Enums\Platform;
use Phizz\Enums\Regional;
// League of Legends
$match = Phizz::lol()->matchV5->getMatch('EUW1_1234567890');
$summoner = Phizz::lol()->summonerV4->getByPuuid($puuid);
$mastery = Phizz::lol()->championMasteryV4->getAllChampionMasteriesByPuuid($puuid);
// Per-call platform override
$match = Phizz::lol(Platform::EUW)->matchV5->getMatch('EUW1_1234567890');
// Teamfight Tactics
$tftMatch = Phizz::tft()->matchV1->getMatch('EUW1_1234567890');
$tftLeague = Phizz::tft()->leagueV1->getChallengerLeague();
$tftSummoner = Phizz::tft()->summonerV1->getByPuuid($puuid);
// Valorant
$valMatch = Phizz::val()->matchV1->getMatch($matchId);
$valLeaderboard = Phizz::val()->rankedV1->getLeaderboard('e7a1');
// Legends of Runeterra
$lorMatch = Phizz::lor()->matchV1->getMatch($matchId);
$lorLeaderboard = Phizz::lor()->rankedV1->getLeaderboards();
// Account (cross-game)
$account = Phizz::riot()->accountV1->getByRiotId(gameName: 'IAmTheWhite', tagLine: 'EUW');
// Always fetches fresh data, even when caching is enabled
$match = Phizz::lol()->matchV5->getMatch('EUW1_1234567890', force: true);
use Phizz\TTL;
// config/phizz.php
'cache' => [
'enabled' => env('RIOT_CACHE_ENABLED', true),
'store' => env('RIOT_CACHE_STORE', null),
'default' => env('RIOT_CACHE_TTL', 60),
'method' => [
TTL::lol::matchV5::getMatch => 86400, // matches — cache for 24 h
TTL::lol::matchV5::getTimeline => 86400,
TTL::lol::summonerV4::getByPuuid => 3600, // slow-changing — 1 h
TTL::lol::leagueV4::getChallengerLeague => 300, // rankings — 5 min
TTL::lol::spectatorV5::getCurrentGameInfoByPuuid => 30, // live game — 30 s
],
],
use Phizz\Retry;
// Exponential backoff: 1 s, 2 s, 4 s, 8 s, ... (default)
'retry' => ['strategy' => Retry::exponential()],
// Fixed delay between every attempt
'retry' => ['strategy' => Retry::fixed(seconds: 2)],
use Phizz\Enums\Platform; // na1, euw1, kr, br1, jp1, ...
use Phizz\Enums\Regional; // Americas, Europe, Asia, SEA
use Phizz\Enums\ValPlatform; // NA, EU, AP, KR, BR, LatAm, Esports
// config/phizz.php
return [
// Your Riot Games API key
'api_key' => env('RIOT_API_KEY', ''),
// Default platform used when none is specified per-call
'default_platform' => env('RIOT_DEFAULT_PLATFORM', Platform::NA),
// Maximum seconds to wait for a response before timing out
'timeout' => env('RIOT_TIMEOUT', 60),
// Retry strategy on 429 responses
'retry' => [
'strategy' => Retry::exponential(),
],
// Response caching
'cache' => [
'enabled' => env('RIOT_CACHE_ENABLED', true),
'store' => env('RIOT_CACHE_STORE', null), // null = app default
'default' => env('RIOT_CACHE_TTL', 60), // fallback TTL in seconds
'method' => [
// Per-endpoint TTL overrides using TTL constants
TTL::lol::matchV5::getMatch => 86400,
// ...
],
],
// Log all requests and responses (useful for debugging)
'logging' => [
'enabled' => env('RIOT_LOGGING_ENABLED', false),
],
];
bash
php artisan vendor:publish --tag="phizz-config"