Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to SS 5 and CloudFlare Official SDK, closes #4 #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/tests/assets/
/.phpunit.result.cache
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2017, Symbiote.
Copyright (c) 2024, Symbiote.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
# Old Man

[![Build Status](https://travis-ci.org/symbiote/silverstripe-oldman.svg?branch=master)](https://travis-ci.org/symbiote/silverstripe-oldman)
[![Latest Stable Version](https://poser.pugx.org/symbiote/silverstripe-oldman/version.svg)](https://github.com/symbiote/silverstripe-oldman/releases)
[![Latest Unstable Version](https://poser.pugx.org/symbiote/silverstripe-oldman/v/unstable.svg)](https://packagist.org/packages/symbiote/silverstripe-oldman)
[![Total Downloads](https://poser.pugx.org/symbiote/silverstripe-oldman/downloads.svg)](https://packagist.org/packages/symbiote/silverstripe-oldman)
[![License](https://poser.pugx.org/symbiote/silverstripe-oldman/license.svg)](https://github.com/symbiote/silverstripe-oldman/blob/master/LICENSE.md)

A module to aid in the purging of Cloudflare caches.

![oldman-cloud](https://user-images.githubusercontent.com/3859574/31596225-d2213356-b28c-11e7-97c3-e73500083c34.png)

## Composer Install

**[SilverStripe 3.X](https://github.com/symbiote/silverstripe-oldman/tree/1)**
```
composer require symbiote/silverstripe-oldman:~1.0
```

**[SilverStripe 4.X](https://github.com/symbiote/silverstripe-oldman/tree/master)**
```
composer require symbiote/silverstripe-oldman:~3.0
composer require symbiote/silverstripe-oldman:^4
```

## Requirements

* PHP 5.4+
* SilverStripe 3.2+
* PHP 7.4+
* Silverstripe 4+ | 5+

## Documentation

Expand All @@ -38,3 +26,4 @@ composer require symbiote/silverstripe-oldman:~3.0

* [Steadlane Cloudflare](https://github.com/steadlane/silverstripe-cloudflare) for being the basis for this module
* [James Bell](https://github.com/jamesryanbell/cloudflare) for his Cloudflare Library
* [UndefinedOffset](https://github.com/webbuilders-group/silverstripe-oldman) for the SS 5 upgrade and adaptation for the official Cloudflare API
4 changes: 4 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ Name: cloudflare_extensions
SilverStripe\CMS\Model\SiteTree:
extensions:
- Symbiote\Cloudflare\SiteTreeExtension

SilverStripe\Assets\File:
extensions:
- Symbiote\Cloudflare\FileExtension
18 changes: 7 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"description": "A simple cache purging module for Silverstripe.",
"type": "silverstripe-vendormodule",
"keywords": [
"silverstripe"
"silverstripe",
"cloudflare",
"cache"
],
"license": "BSD-3-Clause",
"authors": [
Expand All @@ -17,13 +19,13 @@
}
],
"require": {
"php": ">=5.6",
"silverstripe/cms": "^4.0",
"jamesryanbell/cloudflare": "~1.11"
"php": ">=8.1",
"silverstripe/cms": "^4|^5",
"cloudflare/sdk": "~1.3"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.0",
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^9.5"
},
"scripts": {
"phpcbf": "phpcbf -n src/ tests/"
Expand All @@ -33,12 +35,6 @@
"Symbiote\\Cloudflare\\": "src/",
"Symbiote\\Cloudflare\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
},
"installer-name": "oldman"
},
"replace": {
"silbinarywolf/silverstripe-oldman": "self.version"
Expand Down
18 changes: 18 additions & 0 deletions docs/en/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,31 @@

2. Configure in YML, example below:
```yml
Symbiote\Cloudflare\Cloudflare:
enabled: true
api_token: '24ca61e15fb2aa62a31-212a90f2674f_3451f8' # Needs the the "Cache Purge" permission:
zone_id: '73a40b2c0c10f468cb658f67b9d46fff'
```

Alternatively you can use you Global API Key:
```yml
Symbiote\Cloudflare\Cloudflare:
enabled: true
email: 'silverstripe@gmail.com'
auth_key: '24ca61e15fb2aa62a31212a90f2674f3451f8'
zone_id: '73a40b2c0c10f468cb658f67b9d46fff'
```

Note the `email`, `auth_key`, `zone_id`, and `api_token` yaml options can also be represented with service properties so you can store this information in the environment file. For example:

```yml
Symbiote\Cloudflare\Cloudflare:
enabled: true
api_token: "`CLOUDFLARE_API_TOKEN`"
zone_id: "`CLOUDFLARE_ZONE_ID`"
```


3. Publishing / unpublishing a page from the CMS will now clear the Cloudflare cache for that URL.

4. For clearing CSS, JavaScript and images from the Cloudflare cache, see the [Advanced Usage](advanced-usage.md) section.
Expand Down
25 changes: 13 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
<testsuite name="Default">
<directory>tests/</directory>
</testsuite>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="../../silverstripe/cms/tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory suffix=".php">tests/</directory>
</exclude>
</coverage>
<testsuite name="Default">
<directory>tests/</directory>
</testsuite>
</phpunit>
Loading