PHP code example of ghostcompiler / laravel-cloudflare

1. Go to this page and download the library: Download ghostcompiler/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/ */

    

ghostcompiler / laravel-cloudflare example snippets


use Vendor\Cloudflare\Facades\Cloudflare;

$zones = Cloudflare::zones()
    ->filter(['status' => 'active'])
    ->perPage(50)
    ->page(1)
    ->get();

foreach ($zones as $zone) {
    echo $zone->name . ': ' . $zone->status . "\n";
}

// Create a new record
$record = Cloudflare::dns()->create('zone_id_here', [
    'type' => 'A',
    'name' => 'subdomain',
    'content' => '1.2.3.4',
    'proxied' => true,
    'ttl' => 1
]);

// Update the record
Cloudflare::dns()->update('zone_id_here', $record->id, [
    'type' => 'A',
    'name' => 'subdomain',
    'content' => '5.6.7.8',
    'proxied' => false,
    'ttl' => 120
]);

// Delete the record
Cloudflare::dns()->delete('zone_id_here', $record->id);

Cloudflare::workers()->upload('account_id_here', 'my-script', 'console.log("Hello Worker");');
bash
php artisan vendor:publish --provider="Vendor\Cloudflare\Providers\CloudflareServiceProvider" --tag="config"