Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 426b5d9

Browse files
committed
Forgot to update this portion too.
1 parent 8370c22 commit 426b5d9

1 file changed

Lines changed: 57 additions & 19 deletions

File tree

README.md

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,99 @@
22
[![Latest Stable Version](https://poser.pugx.org/paladinsdev/php-api/v/stable)](https://packagist.org/packages/paladinsdev/php-api) [![License](https://poser.pugx.org/paladinsdev/php-api/license)](https://packagist.org/packages/paladinsdev/php-api) [![Total Downloads](https://poser.pugx.org/paladinsdev/php-api/downloads)](https://packagist.org/packages/paladinsdev/php-api) [![Build Status](https://img.shields.io/travis/PaladinsDev/PHP-API.svg)](https://travis-ci.org/PaladinsDev/PHP-API)
33

44
## About
5+
56
This PHP package came from the need to have a well documented, functional package to help communicate with the Paladins developer API. This package is built using Laravel 5 components and has not been tested outside of that environment.
67

8+
79
## Installation
10+
811
```sh
12+
913
$ composer require paladinsdev/php-api
14+
1015
```
1116

17+
1218
## Usage
19+
1320
There are two ways of using the class, however only 1 recommended. The singleton method is used on [Paladins Ninja](https://paladins.ninja) and handles hundreds of thousands a matches a day.
1421

22+
1523
### Recommended (Singleton)
24+
1625
```php
17-
<?php
1826

27+
<?php
1928
use PaladinsDev\PHP\PaladinsAPI;
2029

21-
class YourClass
30+
class YourClass
2231
{
23-
public function getSomePlayer()
24-
{
25-
$playerDetails = PaladinsAPI::getInstance('YourDevId', 'YourDevAuthKey')->getPlayer('SomePlayer');
26-
}
32+
public function getSomePlayer()
33+
{
34+
$playerDetails = PaladinsAPI::getInstance('YourDevId', 'YourDevAuthKey', $cacheDriver)->getPlayer('SomePlayer');
35+
}
2736
}
2837
```
2938

3039
#### Using This Method (Laravel)
40+
3141
Laravel makes it very easy to use singletons using the `resolve()` helper. Open up the `app.php` file in the `bootstrap` folder at the root of your project directory and add the following piece of code.
3242

43+
3344
```php
45+
3446
$app->singleton('PaladinsAPI', function($app) {
35-
return PaladinsDev\PHP\PaladinsAPI::getInstance(env('PALADINS_DEVID'), env('PALADINS_AUTHKEY'));
47+
return PaladinsDev\PHP\PaladinsAPI::getInstance(env('PALADINS_DEVID'), env('PALADINS_AUTHKEY'), $cacheDriver);
3648
});
49+
3750
```
51+
3852
This assumes you have two environment variables `PALADINS_DEVID` and `PALADINS_AUTHKEY`. You can edit this however you like. You use it by calling `resolve('PaladinsAPI')` and then use it just like a normal instance of a class.
3953

54+
4055
### Not Recommended
56+
4157
*This is not recommended as Hi-Rez / Evil Mojo only allows so many sessions a day and the more sessions you create, the quicker you'll get to reaching that limit. Caching **should** be able to handle this method...but it's still not recommended.*
4258

59+
4360
```php
61+
4462
<?php
4563

4664
use PaladinsDev\PHP\PaladinsAPI;
47-
65+
4866
class YourClass
4967
{
50-
private $api;
51-
52-
public function __construct()
53-
{
54-
$this->api = new PaladinsAPI('YourDevId', 'YourDevAuthKey');
55-
}
56-
57-
public function getSomePlayer()
58-
{
59-
$playerDetails = $this->api->getPlayer('SomePlayer');
60-
}
68+
private $api;
69+
70+
public function __construct()
71+
{
72+
$this->api = new PaladinsAPI('YourDevId', 'YourDevAuthKey', $cacheDriver);
73+
}
74+
75+
public function getSomePlayer()
76+
{
77+
$playerDetails = $this->api->getPlayer('SomePlayer');
78+
}
6179
}
80+
6281
```
82+
83+
## Cache Driver
84+
To uncouple the Laravel/Iluminate framework from the package, we've taken a page from TeamReflex's book and integrated [Onoi Cache](https://packagist.org/packages/onoi/cache).
85+
86+
You can pass the driver as the 3rd parameter of the constructor or `getInstance` method.
87+
88+
### Illuminate Driver
89+
#### Install
90+
```
91+
composer require halfpetal/illuminate-onoi-cache
92+
```
93+
94+
#### Usage
95+
```php
96+
use Halfpetal\Onoi\Illuminate\Cache;
97+
use lluminate\Cache\Repository;
98+
99+
$cacheDriver = new Cache(app(Repository::class));
100+
```

0 commit comments

Comments
 (0)