biozahard/yii2-cloudflare-api

Simple Yii2 cloudflare extension without any requirements.

dev-master 2017-04-11 12:20 UTC

This package is not auto-updated.

Last update: 2024-04-14 00:28:21 UTC


README

Yii2 Component for CloudFlare api v4.0. https://www.cloudflare.com/

Minimum requirements: Yii2, Curl

Installation via Composer:

composer require biozahard/yii2-cloudflare-api

Configuring in config.php:

'components' => [
//...
        'cloudflare' => [
            'class'         => 'biozahard\cloudflare\CloudflareApi',
            'apiurl'   => 'https://api.cloudflare.com/client/v4/',
            'authkey'       => '5gds0kfdsc024ndsofsj049jisdofjsd034jw',
            'authemail'     => 'admin@mail.com',
            'sites'         => [
                'mysite.com',
                'thebest-country.ua',
                'anotheronesite.biz',
            ],
        ],
//...
]

After this configuring you can use: \Yii::$app->cloudflare

So, let's see some examples:

  1. Purge all cloudflare cache:
//get the CloudFlare api component
$cf = \Yii::$app->cloudflare;

//purge cache for specific website:
$cf->purgeCache('thebest-country.ua');

//Clear the cache for the first site from the specified list:
$cf->purgeCache();

License: LGPL v3 or later