Code Monkey home page Code Monkey logo

artisan-cloudflare's Introduction

Laravel artisan commands for Cloudflare

Latest Version on Packagist Software License Build Status Quality Score Scrutinizer Coverage StyleCI

Laravel artisan commands for interacting with the CloudFlare API.

artisan-cloudflare.png

Installation

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,
],

Configuration

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' => [
        //
    ],
];

Usage

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.

Purge all the zones with their files and tags.

php artisan cloudflare:cache:purge

Purge a single zone.

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

Purge individual files from all the zones.

php artisan cloudflare:cache:purge --file="http://example.com/css/app.css" --file="http://example.com/img/logo.svg"

Purge individual tags from all the zones.

Purging tags is available for Enterprise accounts only.

php artisan cloudflare:cache:purge --tag=styles --tag=scripts

Purge individual hosts from all the zones.

Purging hosts is available for Enterprise accounts only.

php artisan cloudflare:cache:purge --host=www.example.com --host=images.example.com

Purge individual files, tags, and hosts from all the zones.

php artisan cloudflare:cache:purge --file="http://example.com/css/app.css" --tag=scripts --tag=images --host=www.example.com

Purge individual files, tags, and hosts from a single zone.

php artisan cloudflare:cache:purge 023e105f4ecef8ad9ca31a8372d0c353 --file="http://example.com/css/app.css" --tag=scripts --tag=images --host=www.example.com

Changelog

Please see CHANGELOG for more information on what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

artisan-cloudflare's People

Contributors

ctf0 avatar pelmered avatar sebdesign avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.