PHP code example of dimuska139 / rawg-sdk-php

1. Go to this page and download the library: Download dimuska139/rawg-sdk-php 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/ */

    

dimuska139 / rawg-sdk-php example snippets



use Rawg\ApiClient;
use Rawg\Config;
use Rawg\DateRange;
use Rawg\Filters\GamesFilter;
use Rawg\Filters\PaginationFilter;

$cfg = new Config('api-key', 'en');
$client = new ApiClient($cfg);

$additionsFilter = (new PaginationFilter())->setPage(1)->setPageSize(5);
print_r($client->games()->getAdditions(47, $additionsFilter)->getData());

$gamesFilter = (new GamesFilter())
    ->setPage(1)
    ->setPageSize(20)
    ->setDates([
        DateRange::create(new DateTime( '2012-02-01' ), new DateTime( '2015-06-25' ))
    ])
    ->setOrdering('-name')
    ->setTags([1,2,3]);

print_r($client->games()->getGames($gamesFilter)->getData());