Note: This library is under active development as I expand it to cover Cloudflare API. Consider the public API of this package a little unstable as I work towards a v1.0. See Coverage.

Zones

Domains (or subdomains) that are added to Cloudflare become zones, which have a direct impact on the security and performance of your website, application, or API. Use your zone to monitor security and performance, update configurations, and apply zone-level products and services.

Cloudflare API docs

List

Lists, searches, sorts, and filters your zones. Listing zones across more than 500 accounts is currently not allowed.

php
$response = $client->zones()->list('ACCOUNT_ID');

Create

Create Zone for the account.

php
$values = [
    'name' => 'The domain name'
];

$response = $client->zones()->create('ACCOUNT_ID', $values);

Details

Get Zone Details.

php
$response = $client->zones()->details('ZONE_ID');

Edit

Edit Zone.

php
$values = [
    'plan' => 'free'
];

$response = $client->zones()->update('ZONE_ID');

Activation Check

Triggeres a new activation check for a PENDING Zone. This can be triggered every 5 min for paygo/ent customers, every hour for FREE Zones.

php
$response = $client->zones()->activationCheck('ZONE_ID');

Purge Cached Content

Purge Cached Content

php
$values = [
    'tags' => ['my-custom-cache-tag']
];


$response = $client->zones()->purge('ZONE_ID', $values);

Using CachePurge Configuration helper.

php
use Cloudflare\Configurations\Zones\CachePurge;

$config = (new CachePurge())
    ->byTags(['my-custom-cache-tag']);

// OR

$config = (new CachePurge())->everything();

$response = $client->zones()->purge('zone_id', $config);

Delete

Delete Zone.

php
$response = $client->zones()->delete('ZONE_ID');