ali1 / cakephp-cloudflare-api
A CakePHP component to use the CloudFlare in PHP
Installs: 2 855
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Type:cakephp-plugin
Requires
- composer/installers: *
- vexxhost/cloud-flare-api: dev-master
This package is auto-updated.
Last update: 2020-02-17 20:44:01 UTC
README
This plugin is a (very) thin veil over vexxhost's CloudFlare-API for use in CakePHP controllers. Please use composer to install so that the required dependencies are installed
Composer Installation
-
Add to composer, this will also install the Amazon SDK for PHP as a dependency
"ali1/cakephp-cloudflare-api": "dev-master"
Non-composer Installation
- Place the contents of this repo in Plugin/CloudFlareApi
- Download the contents of https://github.com/vexxhost/CloudFlare-API into Plugin/CloudFlareApi/Vendor/vexxhost/cloud-flare-api
Configuration
-
You must add configuration to bootstrap.php.
Configure::write('CloudFlareApi.email', 'CLOUDFLARE EMAIL'); Configure::write('CloudFlareApi.apiKey', 'CLOUDFLARE API KEY');
- Don't forget to replace the placeholder text with your actual keys!
-
Add the component to a controller
public $components = array('CloudFlareApi.CloudFlareApi');
Example
-
Remove a file from the cache
$this->CloudFlareApi->zone_file_purge('mydomain.com', 'http://forum.mydomain.com/images/logo.png');
-
From a model or shell
if (!isset($this->CloudFlareApi)) { App::import('Component', 'CloudFlareApi.CloudFlareApi'); $collection = new ComponentCollection(); $Controller =& new Controller(); $this->CloudFlareApi = new CloudFlareApiComponent($collection); $this->CloudFlareApi->initialize($Controller); } $this->CloudFlareApi->zone_file_purge('mydomain.com', 'http://forum.mydomain.com/images/logo.png');
-
From a console
Console/cake CloudFlareApi.call fpurge_ts mydomain.com Console/cake CloudFlareApi.call zone_file_purge mydomain.com http://forum.mydomain.com/images/logo.png
Notes
You can find the method definitions here: https://github.com/vexxhost/CloudFlare-API/blob/master/class_cloudflare.php