Skip to content

ofahel/Minimalist-CloudFlare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Minimalist CloudFlare API

The fastest and simplest PHP CloudFlare API

ZeosDev

This project is the simplest way to manage DNS Records on CloudFlare.

Make simple things to do complex task

As Steve Jobs says on the BusinessWeek, May 25 1998

That’s been one of my mantras — focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it’s worth it in the end because once you get there, you can move mountains.

⚡ Features

  • Easy way to manage your DNS Records.

  • Create Records.

  • Edit Records.

  • List Zone Records.

  • Lightest CloudFlare PHP API.

🎉 Installation/Usage

Download the cf_api.php and put it on your project folder.

Follow the example and voilà.

<?php
include("cf_api.php");

//Instantiate the API class => (Email, CF Auth key, Zone ID)
$CloudFlare = new CloudFlareAPI("[email protected]", "9ca34...", "2fc20...");

//Create A DNS Record
$params = array(
              "type" => "A",
              "name" => "something",
              "content" => "8.8.8.8",
              "ttl" => 120 /*OPTIONAL*/,
              "priority" => 10 /*OPTIONAL*/,
              "proxied" => true /*OPTIONAL*/);
$CloudFlare->createRecord($params);


//Edit or Update a DNS Record
$record_id = "27eeb..."; //Record ID
$params = array(
               'type' => 'A',
               'name' =>' something',
               'content' => '216.58.202.206',
               'ttl' => 10 /*OPTIONAL*/,
               'proxied' => true /*OPTIONAL*/);

$CloudFlare->updateRecord($record_id, $params);


//List DNS Records
$params = array(
              "type" => "A" /*OPTIONAL*/,
              "name" => "something" /*OPTIONAL*/,
              "proxied" => true /*OPTIONAL*/,
              "page" => 0 /*OPTIONAL*/,
              "order" => 10 /*OPTIONAL*/,
              "content" => true /*OPTIONAL*/);
              
$CloudFlare->listRecords($params /*OPTIONAL*/);


//Delete DNS Record
$record_id = "59ae3..."; //Record ID
$CloudFlare->deleteRecord($record_id);

...

✨ Create Record Parameters

Parameter Description Rule Default Type
type More details on Supported Types of DNS Records table Needed string
name The name of the DNS Record Needed string
content The content of the DNS Record Needed string
ttl Time to Live of the DNS Record Optional 120 int
priority Priority are used by MX Hosts, check your host tutorial Optional 10 int
proxied Record proxied by CloudFlare Optional true boolean

📄 List Records Parameters

Parameter Description Rule
type Filter by Record Type Optional
name Filter by Record Name Optional
content Filter by Record Content Optional
ttl Filter by Record TTL Optional
priority Filter by Record Priority Optional
proxied Filter by Record Proxied Optional

🖊️ Edit/Update Record Parameters

Parameter Description Rule Default Type
type More details on Supported Types of DNS Records table Needed string
name The name of the DNS Record Needed string
content The content of the DNS Record Needed string
ttl Time to Live of the DNS Record Optional 120 int
proxied Record proxied by CloudFlare Optional true boolean

🧐 Supported Types of DNS Records

Type Description
A The record that holds the IP address of a domain. more...
CNAME Forwards one domain or subdomain to another domain, does NOT provide an IP address. more...
MX Directs mail to an email server. more...
TXT Lets an admin store text notes in the record. more...
NS Stores the name server for a DNS entry. more...
SOA Stores admin information about a domain. more...
SRV Specifies a port for specific services. more...
PTR Provides a domain name in reverse-lookups. more...

🧭 API Methods

Method Description Parameters
CURL Execute your own PostField to CloudFlare API API Type, Posts (json string)
changeZone Change Zone prop Zone(string)
createRecord Create a new Record Object(type, name, content, proxied)
listRecords List zone DNS Records Object(type, name, proxied, content, page, order)
updateRecord Create a new Record Object(type, name, content, ttl, proxied)
deleteRecord Delete a Record by their ID Record ID(string)

️📑️ TODO

  • Implement (delete) DNS Records️ (Done ✔️)
  • Implement (edit) DNS Records (Done ✔️)
  • Implement (list) DNS Records (Done ✔️)

👨‍💻 Development

Want to contribute? Great! You are welcome 🥳

License

GNU General Public License

About

Fastest, lightest and simplest CloudFlare API

Topics

Resources

License

Stars

Watchers

Forks

Languages