whatdafox/keycdn

This package is abandoned and no longer maintained. No replacement package was suggested.

KeyCDN API PHP SDK

1.0.1 2017-04-07 10:05 UTC

This package is auto-updated.

Last update: 2021-06-11 14:43:54 UTC


README

Packagist Travis

PHP Wrapper to interact with the KeyCDN API.

Installation

composer require whatdafox/keycdn

Usage

Simply create an KeyCDN object, with a valid API Token in the constructor:

$keycdn = KeyCDN::create($token);

Zones

// List all zones
$keycdn->zones()->all();

// View one specific zone
$keycdn->zones()->find($zoneId);

// Add a zone
$keycdn->zones()->add('foo', 'pull', 'http://foo.com');

// Edit a zone
$keycdn->zone($zoneId)->update([
    'gzip' => 'enabled'
]);

// Delete a zone
$keycdn->zone($zoneId)->delete();

// Purge a zone
$keycdn->zone($zoneId)->purge();

// Purge URLs
$keycdn->zone($zoneId)->purge(['http://foo.com']);
$keycdn->zone($zoneId)->purgeUrls(['http://foo.com']);

// Purge Tags
$keycdn->zone($zoneId)->purge(['http://foo.com'], true);
$keycdn->zone($zoneId)->purgeTags(['http://foo.com']);

Zone Aliases

// List zone aliases
$keycdn->aliases()->all();

// Add a zone alias
$keycdn->aliases()->add($zoneId, 'cdn.foo.com');

// Edit a zone alias
$keycdn->alias($aliasId)->update([
    'name' => 'cdn.bar.com'
]);

// Delete a zone alias
$keycdn->alias($aliasId)->delete();

Zone Referrers

// List zone referrers
$keycdn->referrers()->all();

// Add a zone referrer
$keycdn->referrers()->add($zoneId, 'cdn.foo.com');

// Edit a zone referrer
$keycdn->referrer($referrerId)->update([
    'name' => 'cdn.bar.com'
]);

// Delete a zone referrer
$keycdn->referrer($referrerId)->delete();

Reports

Examples using Carbon/Carbon

// Traffic
$keycdn->traffic(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);
$keycdn->traffic(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp, ZONE_ID);

// Storage
$keycdn->storage(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);
$keycdn->storage(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp, ZONE_ID);

// Status
$keycdn->status(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);
$keycdn->status(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp, ZONE_ID);

// Credits
$keycdn->credits(Carbon::now()->subDays(30)->timestamp, Carbon::now()->timestamp);