PHP code example of leknoppix / laravel-cloudflare
1. Go to this page and download the library: Download leknoppix/laravel-cloudflare library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return [
/*
|--------------------------------------------------------------------------
| Cloudflare Site
|--------------------------------------------------------------------------
|
| Specify the sitename of the Cloudflare.
|
*/
'sitename' => env('CLOUDFLARE_SITE', 'test.com'),
/*
|--------------------------------------------------------------------------
| Cloudflare Authentication Email
|--------------------------------------------------------------------------
|
| Specify the authentication email to access Cloudflare.
|
*/
'auth_email' => env('CLOUDFLARE_AUTH_EMAIL', '[email protected]'),
/*
|--------------------------------------------------------------------------
| Cloudflare Authentication Key
|--------------------------------------------------------------------------
|
| Specify the authentication key to access Cloudflare.
|
*/
'auth_key' => env('CLOUDFLARE_AUTH_KEY', 'test_auth_key'),
];
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Leknoppix\Cloudflare\Model\Concerns\Cloudflare;
class Post extends Model
{
use Cloudflare;
}
namespace App\Listeners;
use Illuminate\Contracts\Queue\ShouldQueue;
use Leknoppix\Cloudflare\Events\ModelHasUpdated;
class PurgeCloudflareCache implements ShouldQueue
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param ModelHasUpdated $event
* @return void
*/
public function handle(ModelHasUpdated $event): void
{
//handle the Cloudflare purging
}
}