Download the PHP package michaelgarrez/lol-api without Composer
On this page you can find all versions of the php package michaelgarrez/lol-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download michaelgarrez/lol-api
More information about michaelgarrez/lol-api
Files in michaelgarrez/lol-api
Package lol-api
Short Description Wrapper for League of Legends API
License MIT
Informations about the package lol-api
League of Legends API wrapper in PHP
Introduction
Simple PHP wrapper for League of legends API.
This library implements two custom exceptions to catch your API rate limits (ServiceRateLimitException && UserRateLimitException).
It also implements Doctrine cache to cache the API results into your favorite cache driver.
Migration from 0. to 1.
Three main features breaking BC caused a bump to the 1.* version:
- Cache implementation
- AbstractRateLimitException
- Return of an ApiResult object instead of an array
Only the third one can actually break BC. You should now use the getResult() method on the ApiResult object returned.
How to use
Basic use
You first have to select the API you want to fetch from and then the specific method. Each call will return an ApiResult object containing the URL called, the Guzzle Response object and an array containing the API result.
To get the result you can call the method getResult() on the ApiResult object.
Use cache
By default Symfony NullAdapter cache is used. You can specify another Cache Adapter (implementing PSR6 Adapters) to the ApiClient.
Example with Predis :
The default ttl value cacheApiResult() method is 60 seconds.
Rate limit
When you reach the rate limit (User or Service) the library will throw you an implementation of the AbstractRateLimitException. You can get the type of rate limit and the time to wait before a new call (Riot is very strict on the rate limit respect).
Example with a sleep :
API implemented
API | Version |
---|---|
Summoner API | |
Match API | |
Champion API | |
Spetactor API | |
Static Data API | |
League API | |
Status API | |
Champion Mastery API | |
Masteries API | |
Runes API |
Contributing
Please create issues if you have any problem with this library integration.
If you want to contribute, create a PR, you must respect PSR-2 and your code must be tested.
Thank you !