A simple PHP Client for Cloudflare API.
Note: This package 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
This package provides convenient access to the Cloudflare REST API using PHP.
- PHP >= 8.2
- Minimal API around the Guzzle HTTP client
- Light and fast thanks to lazy loading of API classes
- Extensively documented
- Laravel >= 12 support
Via Composer.
This command will get you up and running quickly.
composer require sergkeim/php-cloudflare-apiIf you don't have PHP/Composer installed locally, a Docker setup is provided so you can install dependencies and run the test suite without installing anything on your machine.
A ./dock helper script wraps the common docker compose commands (it starts the container automatically if it isn't already running):
./dock build # Build the image (only needed once, or after Dockerfile changes)
./dock install # composer install
./dock test # Run the full PHPUnit suite
./dock test --filter=SslTest # Pass any args straight through to phpunit
./dock cs # Check code style (php-cs-fixer, dry run)
./dock fix # Fix code style (php-cs-fixer)
./dock sh # Open a shell in the container
./dock down # Stop and remove the container
./dock matrix # Run the full PHP x Laravel support matrix locally (mirrors CI)
./dock help # List all commandsThis package requires PHP >= 8.2 and supports Laravel 12 and 13 (via illuminate/contracts and illuminate/support). ./dock matrix builds and tests every supported PHP/Laravel combination locally, in isolated containers, mirroring .github/workflows/tests.yml:
| PHP | Laravel 12 | Laravel 13 |
|---|---|---|
| 8.2 | ✅ | ❌ |
| 8.3 | ✅ | ✅ |
| 8.4 | ✅ | ✅ |
| 8.5 | ✅ | ✅ |
Each matrix cell runs composer update and the full test suite inside its own container/vendor volume, so runs never interfere with each other or with your host composer.json/composer.lock.
Or use docker compose directly if you prefer:
docker compose build
docker compose up -d
docker compose exec php composer install
docker compose exec php composer test
docker compose downThe php service mounts the repository into the container, so changes you make on your host are picked up immediately without rebuilding.
- Thanks to Cloudflare for the high quality API and documentation.
- Thanks to KnpLabs for php-github-api used as inspiration for this package.
- Thanks to Graham Campbell for Laravel TestBench.
php-cloudflare-api is licensed under the MIT License - see the LICENSE file for details
Cloudflare, the Cloudflare logo, and Cloudflare Workers are trademarks and/or registered trademarks of Cloudflare, Inc. in the United States and other jurisdictions.