team-reflex / challonge-php
PSR-18 compatible library to interface with the bracket generator Challonge.
Installs: 27 471
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 9
Forks: 9
Open Issues: 2
Requires
- php: ^8.1 | ^8.2
- ext-json: *
- illuminate/collections: ~9| ~10
- nyholm/psr7: ^1.6.1
- psr/http-client: ^1.0
- psr/log: ^3.0
- spatie/data-transfer-object: ^2.5
Requires (Dev)
- guzzlehttp/guzzle: ^7.4.5
- php-http/mock-client: ^1.4
- phpunit/phpunit: ^9.4
- symfony/http-client: ^5.3
This package is auto-updated.
Last update: 2024-11-13 16:47:49 UTC
README
PSR-18 compliant package for interfacing with the Challonge API.
Installation
Refer to the table for PHP version compatibility:
Install via composer:
composer require team-reflex/challonge-php:version
Usage
As the package is PSR-18 compliant, it does not come with an HTTP client by default.
You can use a client such as Guzzle, and pass an instance of it when instantiating:
$http = new GuzzleHttp\Client(); $challonge = new Challonge($http, 'api_key_here', true);
By default, the package maps the keys of any input, as Challonge requires its input to be in a format such as:
$tournament = $challonge->createTournament([ 'tournament[name]' => 'test' ]);
Which means you are able to use the package without prefixing your keys:
$tournament = $challonge->createTournament([ 'name' => 'test' ]);
You can change the third argument to false
to disable this mapping if you would prefer to do it yourself.
Now you're ready to make requests:
$tournament = $challonge->fetchTournament('challongephptest');
API Updates
Challonge does not lock their API and has been consistently adding new fields to objects, thus breaking strongly typed DTOs.
As of 3.0.4, all three DTOs have been marked to ignore missing fields. If Challonge adds a new field, it will no longer throw a DataTransferObjectError
, but the DTO will also however not contain that new field.
Documentation
As the package is fully type-hinted, everything should be self documenting, however there is documentation in the wiki.