PHPackages                             ak86/php-cloudflare-api-client - 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. ak86/php-cloudflare-api-client

ActiveLibrary[API Development](/categories/api)

ak86/php-cloudflare-api-client
==============================

A PHP based client library for simplifying Cloudflare API operations.

v1.0.6(4y ago)017MITPHPPHP &gt;=5.6

Since Oct 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/amilak86/php-cloudflare-api-client)[ Packagist](https://packagist.org/packages/ak86/php-cloudflare-api-client)[ RSS](/packages/ak86-php-cloudflare-api-client/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

Cloudflare API Client - PHP
===========================

[](#cloudflare-api-client---php)

A PHP based API client library for Cloudflare which lets you execute common cloudflare based operations such as clearing a site cache and switching a site to development mode etc., directly through a PHP script without having to log into the cloudflare dashboard.

Requirements
------------

[](#requirements)

- PHP 5.6 or higher
- Composer package manager
- An HTTPS enabled web server. All the requests to Cloudflare API must be sent over HTTPS.
- A Cloudflare API token. You can obtain the API token from your user profile's API Tokens page located at

NOTE: There are two ways to authenticate with the Cloudflare API. The newer API Tokens based authentication or the old API Keys based authentication. If you opt to use the API token based authentication, make sure to have following permissions enabled:

- cache\_purge:edit
- zone\_settings:edit

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

[](#installation)

Open your terminal. Switch to your project's root directory and run below command to install the package:

```
composer require ak86/php-cloudflare-api-client

```

Basic Usage
-----------

[](#basic-usage)

In your script:

```
// require composer autoloader
require_once 'vendor/autoload.php';

// import the library
use Ak86\CF\ApiClient as CloudflareApiClient;

try {
	// Instantiate CloudflareApiClient by passing your cloudflare authentication token
	$cfClient = new CloudflareApiClient('your_cloudflare_auth_token');

	// To clear the cache (i.e. abc.com)
	$res1 = $cfClient->clearCache('abc.com');

	if($res1)
	{
		echo 'Successfully cleared the cache of abc.com';
	}

	// To set a site to development mode (i.e. xyz.com)
	$res2 = $cfClient->enableDevMode('xyz.com');

	switch($res2['set'])
	{
		case 'now':
			echo 'Successfully switched xyz.com to the dev. mode. It will expire in another '. ($res2['time_remaining'] / 60) .' minutes.';
		break;

		case 'before':
			echo 'xyz.com is already switched to the development mode. It will expire in another '. ($res2['time_remaining'] / 60) .' minutes.';
		break;
	}
}
catch (Exception $e){
	// catch and handle exceptions here
	echo $e->getMessage();
	exit;
}

```

Example App
-----------

[](#example-app)

Please check out below repository for a demo project utilizing CloudflareApiClient:

License
-------

[](#license)

[MIT](./LICENSE)

Author
------

[](#author)

[Amila Kalansooriya](https://www.linkedin.com/in/amilakalansooriya/)

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

7

Last Release

1775d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/28174846?v=4)[Amila Kalansooriya](/maintainers/amilak86)[@amilak86](https://github.com/amilak86)

---

Top Contributors

[![amilak86](https://avatars.githubusercontent.com/u/28174846?v=4)](https://github.com/amilak86 "amilak86 (7 commits)")

### Embed Badge

![Health badge](/badges/ak86-php-cloudflare-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/ak86-php-cloudflare-api-client/health.svg)](https://phpackages.com/packages/ak86-php-cloudflare-api-client)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k54](/packages/neuron-core-neuron-ai)[files.com/files-php-sdk

Files.com PHP SDK

2482.9k](/packages/filescom-files-php-sdk)[volcengine/volcengine-php-sdk

119.5k](/packages/volcengine-volcengine-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
