PHP code example of secretwebmaster / laravel-cloudflare
1. Go to this page and download the library: Download secretwebmaster/laravel-cloudflare library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
secretwebmaster / laravel-cloudflare example snippets
use Secretwebmaster\LaravelCloudflare\Client;
// Option 1: Create using .env values
$client = new Client();
// Option 2: Create manually with API Token
$client = new Client('your-api-token');
// Option 3: Create manually with Email + API Key
$client = new Client(null, '[email protected]', 'your-api-key');
// List all zones
$response = $client->zones()->list();
// List zones with pagination
$zones = $client->zones()->list([
'page' => 1,
'per_page' => 20
]);
// Filter zones by status
$zones = $client->zones()->list([
'status' => 'active'
]);
// Get zone information by domain name
$zone = $client->zones()->getByDomain('example.com');
// Quickly get just the zone ID
$zoneId = $client->zones()->getZoneIdByDomain('example.com');
// List all DNS records for a zone
$response = $client->dnsRecords()->list($zoneId);
// Filter by record type
$records = $client->dnsRecords()->list($zoneId, [
'type' => 'A'
]);
// Filter by name
$records = $client->dnsRecords()->list($zoneId, [
'name' => 'www.example.com'
]);
// Combine filters with pagination
$records = $client->dnsRecords()->list($zoneId, [
'type' => 'A',
'page' => 1,
'per_page' => 50
]);