villaflor / laravel-cloudflare
A Laravel client library for accessing Cloudflare APIs
Installs: 64
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/villaflor/laravel-cloudflare
Requires
- php: ^7.3|^8.0
- cloudflare/sdk: dev-master
Requires (Dev)
- ext-json: *
- orchestra/testbench: ^6.13
README
Cloudflare library for Laravel. This library is an expansion of the official Cloudflare PHP SDK
Requirement
- Cloudflare API token
Installation
In terminal
composer require villaflor/laravel-cloudflare
php artisan vendor:publish --provider="Villaflor\Cloudflare\CloudflareServiceProvider"
In .env file add this line
CLOUDFLARE_API_TOKEN={API token here}
Methods Available
CloudflareDNS
addRecordlistRecordsgetRecordDetailsgetRecordIDupdateRecordDetailsdeleteRecord
CloudflareDNSAnalytics
getReportTablegetReportByTime
CloudflareIps
listIPs
CloudflareZone
addZoneactivationCheckpauseunpausegetZoneByIdlistZonesgetZoneIDgetAnalyticsDashboardchangeDevelopmentModegetCachingLevelsetCachingLevelcachePurgeEverythingcachePurgedeleteZone
CloudflareZoneLockdown
listLockdownscreateLockdowngetLockdownDetailsupdateLockdowndeleteLockdown
CloudflareZoneSettings
getMinifySettinggetRocketLoaderSettinggetAlwaysOnlineSettinggetEmailObfuscationSettinggetServerSideExcludeSettinggetHotlinkProtectionSettinggetBrowserCacheTtlSettingupdateBrowserCacheTtlSettingupdateMinifySettingupdateRocketLoaderSettingupdateAlwaysOnlineSettingupdateEmailObfuscationSettingupdateHotlinkProtectionSettingupdateServerSideExcludeSetting
Usage
This library uses Dependency injection. Dependency injection is a fancy phrase that essentially means this: class dependencies are "injected" into the class via the constructor or, in some cases, "setter" methods.
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'); } }