PHP code example of d8-contrib-modules / cloudflarephpsdk

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

    

d8-contrib-modules / cloudflarephpsdk example snippets


$api_key = 'your_cloudflare_api_key';
$user_email = 'your_cloudflare_email'
$api = new \Drupal\cloudflare\ZoneApi($api_key, $user_email );
$zoneId = $api->listZones()[0]->getZoneId();
$zone = $api->loadZone($zoneId);
$zone_settings = $zone-> getSettings();

$result = $api->purgeIndividualFiles($zoneId, array('path1'));
$result = $api->setSecurityLevel($zoneId, 'low');