PHPackages                             christohill/cfl-api-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. christohill/cfl-api-php

AbandonedLibrary[API Development](/categories/api)

christohill/cfl-api-php
=======================

A PHP wrapper for the CFL.ca API

1.0.0(7y ago)110MITPHP

Since Nov 1Pushed 7y ago1 watchersCompare

[ Source](https://github.com/christohill/cfl-api-php)[ Packagist](https://packagist.org/packages/christohill/cfl-api-php)[ Docs](https://github.com/christohill/cfl-api-php)[ RSS](/packages/christohill-cfl-api-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

CFL.ca API wrapper for PHP
==========================

[](#cflca-api-wrapper-for-php)

This is a simple PHP SDK for interacting with the CFL API. All API documentation can be found at .

Installation
------------

[](#installation)

`composer install christohill/cfl-api-php dev-master`

Usage
-----

[](#usage)

`Note: none of the API keys below are valid`

You can request access to the API at [api.cfl.ca/key-request](http://api.cfl.ca/key-request)

All endpoints in the API are mapped to their own methods in the wrapper. You can see all the [method names below](#methods). There is also a [folder full of examples](examples/) to reference.

#### Simple usage

[](#simple-usage)

```
use CFLPHP\Teams\Teams;
$teams = new Teams();
$teams->setKey('edf59be9216e66eb17093574376d4c5f');
$data = $teams->getTeams();
```

#### Setting API key

[](#setting-api-key)

There are a few ways to set an API key.

1. Set an .env variable (CFLPHP\_Key): `CFLPHP_Key="edf59be9216e66eb17093574376d4c5f"`
2. Set as an argument to the constructor: `$teams = new Teams('edf59be9216e66eb17093574376d4c5f')`
3. Use `setKey` setter method after the class has been instantiated:

```
$teams = new Teams();
$teams->setKey('edf59be9216e66eb17093574376d4c5f');
```

#### Request configuration

[](#request-configuration)

Most methods/endpoints accept some sort of configuration (include, sort, filter, pagination). Refer to [method names below](#methods) to see which accept these. These are set as a multidimensional array like this:

```
$config = array(
    'include' => array(),
    'sort' => array(),
    'filter' => array(),
    'pagination' => array()
);

$teams = new Games();
$data = $teams->getGames(2015, $config);
```

There is some special formatting for each config type:

##### Include

[](#include)

The API accepts comma separated values, so just a simple array will work for this:

```
$config = array(
    'include' => array(
        'boxscore',
        'rosters'
    )
);
```

##### Sort

[](#sort)

The API accepts comma separated values, so just a simple array will work for this:

```
$config = array(
    'sort' => array(
        'height',
        '-weight'
    )
);
```

Note: Using **-** in front of the sort term will reverse the order

##### Filter

[](#filter)

The API can accept multiple filters to try and narrow down the data you need. There is a slight change here from the original API to help keep these filters legible.

```
$config = array(
    'filter' => array(
        "team_2 == TOR",
        "team_1 == HAM"
    )
);
```

Instead of using the \[property\]\[operator\] format, the wrapper uses simple strings with PHP style operators. The operators are as follows:

```
'==' => 'eq'
'!=' => 'ne'
'>' => 'gt'
'=' => 'ge'
'
