Skip to content

3. Usage

Kyle edited this page Aug 4, 2022 · 3 revisions

First you need an API key from Challonge. Store this in a configuration file, environment file or whatever you use, so it doesn't get committed and exposed.

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.

Clone this wiki locally