PHP code example of villaflor / laravel-cloudflare

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

    

villaflor / laravel-cloudflare example snippets


use Villaflor\Cloudflare\CloudflareDNS;

class MyClass
{
    private $cloudflareDNS;

    public function __construct(CloudflareDNS $cloudflareDNS)
    {
        $this->cloudflareDNS = $cloudflareDNS;
    }

    public function UpdateDNS()
    {
        $details = [
            'type' => 'A',
            'name' => 'my-domain.com',
            'content' => '1.2.3.4',
            'ttl' => 1,
            'proxied' => true,
        ];

        return $this->cloudflareDNS->updateRecordDetails('zone-id', 'record-id', $details);
    }
    
    public function DetailDNS()
    {
        return $this->cloudflareDNS->getRecordDetails('zone-id', 'record-id');
    }
    
    public function ListDNS()
    {
        return $this->cloudflareDNS->listRecords('zone-id');
    }
}