Download the PHP package ziffmedia/laravel-cloudflare without Composer
On this page you can find all versions of the php package ziffmedia/laravel-cloudflare. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ziffmedia/laravel-cloudflare
More information about ziffmedia/laravel-cloudflare
Files in ziffmedia/laravel-cloudflare
Package laravel-cloudflare
Short Description Cloudflare tagging for eloquent models and middleware, purging via Nova.
License MIT
Informations about the package laravel-cloudflare
Laravel Nova Cloudflare Tool and Field
Features
- Laravel Nova Tool for adding a cache purge page to manually purge specific urls in batches
- Laravel Nova Field for cache purging specific urls or Cache Tags for a resource
- Option to include either the Tool, Field, or both in project
- Option to use urls, Cache Tag header, or both for purging Cloudflare cache
Nova Tool:
Nova Field:
Installation
-
Install the package into your Laravel application.
-
Publish the config file to your application.
- Provide the new config file your Cloudflare Zone and API keys in your .env files.
Nova Tool Integration
To provide the cache purge Tool in your Nova instance, you must register the Tool with your NovaServiceProvider:
For adding permissions to the Tool, please see the Nova documentation.
Note: The Tool is intended only for urls; setup for Cache Tags is not required if only using the Tool or url purging.
Nova Field Integration
To provide the Cache Purge button on any resource, you must reference the Field and make sure that you have setup the appropriate purge method (url or Cache Tag).
Cloudflare Cache-Tag Header Integration
Cloudflare has the ability to use a special Cache-Tag header on requests to purge multiple pages instantly. If you intend to only use url purging, you can skip this step. In order to setup the Cache-Tag header, follow the below steps:
-
Add the Cloudflare Cache-Tag middleware to automatically add the Cache-Tag header to all requests. Because Cloudflare automatically removes the headers, you can use
debug_cache_tags=1
in the querystring of requests to see the output of the header. -
Add the Cloudflare controller concern to tell the page which tags to give the header request. Here is an example implementation for an Article resource:
- Add the Cloudflare model concern to tell the headers which tag to use for a model. Additionally, the
cloudflareTagsToClear
andcloudflareTag
methods can be overwritten to allow for customization of tags or purging of additional resources. Here is a basic example implementation for an Article model:
Config Options
purge_enabled
: Allows for purging to be turned on or offemail
: Email address used for authenticating with Cloudflare APIkey
: Key used to authenticate with Cloudflare APIzone
: Zone used for Cloudflare APIdomains
: An array of domains which are allowed to be purged. All url purge requests will be validated against these domains, if any.