Laravel artisan commands for interacting with the CloudFlare API.
You can install the package via composer. This package requires Laravel 5.5 or higher.
composer require sebdesign/artisan-cloudflare
Since version 5.5, Laravel uses package auto-discovery, so doesn't require you to manually add the ServiceProvider. If you don't use auto-discovery or you are using an older version, add the service provider in config/app.php
.
<?php
'providers' => [
Sebdesign\ArtisanCloudflare\ServiceProvider::class,
],
Publish the config file in config/cloudflare.php
.
To authenticate with an API key set CLOUDFLARE_KEY
and CLOUDFLARE_EMAIL
in the .env
.
Otherwise you can use an API token by setting the CLOUDFLARE_TOKEN
in the .env
.
php artisan vendor:publish --provider="Sebdesign\ArtisanCloudflare\ServiceProvider"
The following options are available:
<?php
return [
/**
* API token generated from the User Profile 'My Profile > Api Tokens > API Tokens' page.
* create token > Edit zone DNS > "Permissions" Zone:Cache Purge:Purge
*/
'token' => env('CLOUDFLARE_TOKEN'),
/**
* Global API Key on the "My Profile > Api Tokens > API Keys" page.
*/
'key' => env('CLOUDFLARE_KEY'),
/**
* Email address associated with your account.
*/
'email' => env('CLOUDFLARE_EMAIL'),
/**
* Array of zones.
*
* Each zone must have its identifier as a key. The value is an
* associated array with *optional* arrays of files and/or tags.
*
* you can find your zoneId under 'Account Home > site > Api'.
*
* E.g.
*
* '023e105f4ecef8ad9ca31a8372d0c353' => [
* 'files' => [
* 'http://example.com/css/app.css',
* ],
* 'tags' => [
* 'styles',
* 'scripts',
* ],
* 'hosts' => [
* 'www.example.com',
* 'images.example.com',
* ],
* ],
*/
'zones' => [
//
],
];
Read more about Purging cached resources from Cloudflare on the support article.
Execute the cloudflare:cache:purge
command in your console or integrate it in your deployment workflow.
php artisan cloudflare:cache:purge
If the zone exists in the config, then its files and tags will be purged. Otherwise everything will be purged from the given zone.
php artisan cloudflare:cache:purge 023e105f4ecef8ad9ca31a8372d0c353
php artisan cloudflare:cache:purge --file="http://example.com/css/app.css" --file="http://example.com/img/logo.svg"
Purging tags is available for Enterprise accounts only.
php artisan cloudflare:cache:purge --tag=styles --tag=scripts
Purging hosts is available for Enterprise accounts only.
php artisan cloudflare:cache:purge --host=www.example.com --host=images.example.com
php artisan cloudflare:cache:purge --file="http://example.com/css/app.css" --tag=scripts --tag=images --host=www.example.com
php artisan cloudflare:cache:purge 023e105f4ecef8ad9ca31a8372d0c353 --file="http://example.com/css/app.css" --tag=scripts --tag=images --host=www.example.com
php artisan cloudflare:waf:block-ip 6.6.6.6
php artisan cloudflare:waf:block-ip 6.6.6.6 023e105f4ecef8ad9ca31a8372d0c353
php artisan cloudflare:waf:block-ip 6.6.6.6 --notes="By Artisan Cloudflare"
php artisan cloudflare:waf:block-ip 6.6.6.6 023e105f4ecef8ad9ca31a8372d0c353 --notes="By Artisan Cloudflare"
Please see CHANGELOG for more information on what has changed recently.
composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email info@sebdesign.eu instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.