From 46ec929a2718c14ef88d5cae4490ce0487e1dcef Mon Sep 17 00:00:00 2001 From: John Lennard Date: Thu, 2 Feb 2023 10:19:40 +1300 Subject: [PATCH 1/2] small updates and tweaks for craft 4.3 and php 8.1 --- composer.json | 7 +++--- src/CacheResponse.php | 16 ++++++++----- src/EventRegistrar.php | 16 ++++++++----- src/Plugin.php | 11 +++++---- src/PurgerFactory.php | 5 +++- src/TagCollection.php | 5 +++- src/TwigExtension.php | 6 +++-- src/behaviors/CacheControlBehavior.php | 20 ++++++++-------- src/behaviors/TagHeaderBehavior.php | 2 +- src/drivers/AbstractPurger.php | 12 +++++----- src/drivers/CachePurgeInterface.php | 6 ++--- src/drivers/Cloudflare.php | 22 +++++++++--------- src/drivers/Dummy.php | 8 +++---- src/drivers/Fastly.php | 24 ++++++++++--------- src/drivers/Keycdn.php | 14 ++++++------ src/drivers/Varnish.php | 12 +++++----- src/events/CacheResponseEvent.php | 10 ++++---- src/events/PurgeEvent.php | 2 +- src/exceptions/CloudflareApiException.php | 2 +- src/exceptions/FastlyApiException.php | 2 +- src/exceptions/KeycdnApiException.php | 2 +- src/jobs/PurgeCacheJob.php | 8 +++---- src/models/Settings.php | 28 ++++++++++++----------- 23 files changed, 132 insertions(+), 108 deletions(-) diff --git a/composer.json b/composer.json index 913f2a1..f24fcf9 100644 --- a/composer.json +++ b/composer.json @@ -24,11 +24,12 @@ } ], "require": { - "craftcms/cms": "^3.2.0", - "guzzlehttp/guzzle": "^6.5.5|^7.2.0" + "craftcms/cms": "^4.3.0", + "guzzlehttp/guzzle": "^7.5.0", + "php": "^8.1.0" }, "require-dev": { - "vimeo/psalm": "^4.4" + "vimeo/psalm": "^5.4.0" }, "autoload": { "psr-4": { diff --git a/src/CacheResponse.php b/src/CacheResponse.php index 71d3309..10c6f0f 100644 --- a/src/CacheResponse.php +++ b/src/CacheResponse.php @@ -1,20 +1,24 @@ -response = $response; } - public function never() + public function never(): void { if (!$this->isWebResponse()) { return; @@ -24,7 +28,7 @@ public function never() $this->response->addCacheControlDirective('no-cache'); } - public function for(string $time) + public function for(string $time): void { if (!$this->isWebResponse()) { return; diff --git a/src/EventRegistrar.php b/src/EventRegistrar.php index 156e44c..1c9d8e3 100644 --- a/src/EventRegistrar.php +++ b/src/EventRegistrar.php @@ -1,4 +1,7 @@ -getConfig()->configDir . DIRECTORY_SEPARATOR . $this->handle . '.php'; diff --git a/src/PurgerFactory.php b/src/PurgerFactory.php index 6f9dfb2..434c793 100644 --- a/src/PurgerFactory.php +++ b/src/PurgerFactory.php @@ -1,4 +1,7 @@ - [ diff --git a/src/behaviors/CacheControlBehavior.php b/src/behaviors/CacheControlBehavior.php index 93c9f38..d4c4a40 100644 --- a/src/behaviors/CacheControlBehavior.php +++ b/src/behaviors/CacheControlBehavior.php @@ -14,7 +14,7 @@ class CacheControlBehavior extends Behavior /** * @var array */ - protected $cacheControl = []; + protected array $cacheControl = []; /** @@ -23,7 +23,7 @@ class CacheControlBehavior extends Behavior * @param string $key The Cache-Control directive name * @param mixed $value The Cache-Control directive value */ - public function addCacheControlDirective(string $key, $value = true) + public function addCacheControlDirective(string $key, $value = true): void { $this->cacheControl[$key] = $value; $this->owner->getHeaders()->set('Cache-Control', $this->getCacheControlHeader()); @@ -34,7 +34,7 @@ public function addCacheControlDirective(string $key, $value = true) * * @param string $key The Cache-Control directive */ - public function removeCacheControlDirective(string $key) + public function removeCacheControlDirective(string $key): void { unset($this->cacheControl[$key]); $this->owner->getHeaders()->set('Cache-Control', $this->getCacheControlHeader()); @@ -48,7 +48,7 @@ public function removeCacheControlDirective(string $key) * * @return bool true if the directive exists, false otherwise */ - public function hasCacheControlDirective(string $key) + public function hasCacheControlDirective(string $key): bool { return array_key_exists($key, $this->cacheControl); } @@ -60,7 +60,7 @@ public function hasCacheControlDirective(string $key) * * @return mixed|null The directive value if defined, null otherwise */ - public function getCacheControlDirective($key) + public function getCacheControlDirective($key): string|null { return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; } @@ -76,7 +76,7 @@ public function getCacheControlDirective($key) * @return int|null Number of seconds * */ - public function getMaxAge() + public function getMaxAge(): int|null { if ($this->hasCacheControlDirective('s-maxage')) { return (int)$this->getCacheControlDirective('s-maxage'); @@ -100,7 +100,7 @@ public function getMaxAge() * * @final since version 3.2 */ - public function setMaxAge($value) + public function setMaxAge($value): static { $this->addCacheControlDirective('max-age', $value); @@ -119,7 +119,7 @@ public function setMaxAge($value) * * @final since version 3.2 */ - public function setSharedMaxAge($value) + public function setSharedMaxAge($value): static { $this->addCacheControlDirective('public'); $this->removeCacheControlDirective('private'); @@ -129,7 +129,7 @@ public function setSharedMaxAge($value) return $this; } - public function getCacheControl() + public function getCacheControl(): array { return $this->cacheControl; } @@ -145,7 +145,7 @@ public function setCacheControlDirectiveFromString(string $value = null) } } - protected function getCacheControlHeader() + protected function getCacheControlHeader(): string { $parts = array(); ksort($this->cacheControl); diff --git a/src/behaviors/TagHeaderBehavior.php b/src/behaviors/TagHeaderBehavior.php index bd0cc3e..e4a0428 100644 --- a/src/behaviors/TagHeaderBehavior.php +++ b/src/behaviors/TagHeaderBehavior.php @@ -20,7 +20,7 @@ class TagHeaderBehavior extends Behavior * * @return bool */ - public function setTagHeader(string $name, array $tags, string $delimiter = null) + public function setTagHeader(string $name, array $tags, string $delimiter = null): bool { $headers = $this->owner->getHeaders(); diff --git a/src/drivers/AbstractPurger.php b/src/drivers/AbstractPurger.php index 826b159..cd8bb0e 100644 --- a/src/drivers/AbstractPurger.php +++ b/src/drivers/AbstractPurger.php @@ -15,9 +15,9 @@ class AbstractPurger extends BaseObject /** * @var bool */ - public $useLocalTags; + public bool $useLocalTags; - public function __construct($config) + public function __construct(array $config = []) { // assign config to object properties parent::__construct($config); @@ -29,7 +29,7 @@ public function __construct($config) * * @return bool */ - public function purgeUrlsByTag(string $tag) + public function purgeUrlsByTag(string $tag): bool { try { if ($urls = $this->getTaggedUrls($tag)) { @@ -60,7 +60,7 @@ public function purgeUrlsByTag(string $tag) * @return array * @throws \yii\db\Exception */ - public function getTaggedUrls($tag) + public function getTaggedUrls($tag): array { // Use fulltext for mysql or array field for pgsql $sql = \Craft::$app->getDb()->getIsMysql() @@ -93,7 +93,7 @@ public function getTaggedUrls($tag) * @return int * @throws \yii\db\Exception */ - public function invalidateLocalCache(array $uids) + public function invalidateLocalCache(array $uids): int { return \Craft::$app->getDb()->createCommand() ->delete(Plugin::CACHE_TABLE, ['uid' => $uids]) @@ -105,7 +105,7 @@ public function invalidateLocalCache(array $uids) * @return int * @throws \yii\db\Exception */ - public function clearLocalCache() + public function clearLocalCache(): int { return \Craft::$app->getDb()->createCommand() ->delete(Plugin::CACHE_TABLE) diff --git a/src/drivers/CachePurgeInterface.php b/src/drivers/CachePurgeInterface.php index ac9cc42..b9062ce 100644 --- a/src/drivers/CachePurgeInterface.php +++ b/src/drivers/CachePurgeInterface.php @@ -13,19 +13,19 @@ interface CachePurgeInterface * * @return bool */ - public function purgeTag(string $tag); + public function purgeTag(string $tag): bool; /** * @param array $urls * * @return bool */ - public function purgeUrls(array $urls); + public function purgeUrls(array $urls): bool; /** * @return bool */ - public function purgeAll(); + public function purgeAll(): bool; } diff --git a/src/drivers/Cloudflare.php b/src/drivers/Cloudflare.php index 6e5ab33..926772d 100644 --- a/src/drivers/Cloudflare.php +++ b/src/drivers/Cloudflare.php @@ -19,15 +19,15 @@ class Cloudflare extends AbstractPurger implements CachePurgeInterface const MAX_URLS_PER_PURGE = 30; - public $apiKey; + public string $apiKey; - public $apiEmail; + public string $apiEmail; - public $apiToken; + public string $apiToken; - public $zoneId; + public string $zoneId; - public $domain; + public string $domain; /** @@ -35,7 +35,7 @@ class Cloudflare extends AbstractPurger implements CachePurgeInterface * * @return bool */ - public function purgeTag(string $tag) + public function purgeTag(string $tag): bool { if ($this->useLocalTags) { return $this->purgeUrlsByTag($tag); @@ -53,7 +53,7 @@ public function purgeTag(string $tag) * @return bool * @throws \ostark\upper\exceptions\CloudflareApiException */ - public function purgeUrls(array $urls) + public function purgeUrls(array $urls): bool { if (strpos($this->domain, 'http') !== 0) { throw new \InvalidArgumentException("'domain' must include the protocol, e.g. https://www.foo.com"); @@ -79,7 +79,7 @@ public function purgeUrls(array $urls) * @return bool * @throws \yii\db\Exception */ - public function purgeAll() + public function purgeAll(): bool { $success = $this->sendRequest('DELETE', 'purge_cache', [ 'purge_everything' => true @@ -101,7 +101,7 @@ public function purgeAll() * @return bool * @throws \ostark\upper\exceptions\CloudflareApiException */ - protected function sendRequest($method = 'DELETE', string $type, array $params = []) + protected function sendRequest($method = 'DELETE', string $type, array $params = []): bool { $client = $this->getClient(); @@ -120,7 +120,7 @@ protected function sendRequest($method = 'DELETE', string $type, array $params = return true; } - private function getClient() + private function getClient(): Client { $headers = [ 'Content-Type' => 'application/json', @@ -141,7 +141,7 @@ private function getClient() ]); } - private function usesLegacyApiKey() + private function usesLegacyApiKey(): bool { return !isset($this->apiToken) && isset($this->apiKey); } diff --git a/src/drivers/Dummy.php b/src/drivers/Dummy.php index 1f3796b..7dc41a1 100644 --- a/src/drivers/Dummy.php +++ b/src/drivers/Dummy.php @@ -18,7 +18,7 @@ class Dummy extends AbstractPurger implements CachePurgeInterface * * @return bool */ - public function purgeTag(string $tag) + public function purgeTag(string $tag): bool { $this->log("Dummy::purgeTag($tag) was called."); @@ -35,7 +35,7 @@ public function purgeTag(string $tag) * * @return bool */ - public function purgeUrls(array $urls) + public function purgeUrls(array $urls): bool { $joinedUrls = implode(',', $urls); $this->log("Dummy::purgeUrls([$joinedUrls]') was called."); @@ -47,7 +47,7 @@ public function purgeUrls(array $urls) /** * @return bool */ - public function purgeAll() + public function purgeAll(): bool { if ($this->useLocalTags) { $this->clearLocalCache(); @@ -62,7 +62,7 @@ public function purgeAll() /** * @param string|null $message */ - protected function log(string $message = null) + protected function log(string $message = null): void { if (!$this->logPurgeActions) { return; diff --git a/src/drivers/Fastly.php b/src/drivers/Fastly.php index 90a64d5..7602f4c 100644 --- a/src/drivers/Fastly.php +++ b/src/drivers/Fastly.php @@ -32,22 +32,22 @@ class Fastly extends AbstractPurger implements CachePurgeInterface /** * @var string */ - public $apiToken; + public string $apiToken; /** * @var string */ - public $serviceId; + public string $serviceId; /** * @var string */ - public $domain; + public string $domain; /** * @var bool */ - public $softPurge = false; + public bool $softPurge = false; /** * Purge cache by tag @@ -56,7 +56,7 @@ class Fastly extends AbstractPurger implements CachePurgeInterface * * @return bool */ - public function purgeTag(string $tag) + public function purgeTag(string $tag): bool { return $this->sendRequest('POST', 'purge', [ 'Surrogate-Key' => $tag @@ -71,13 +71,13 @@ public function purgeTag(string $tag) * * @return bool */ - public function purgeUrls(array $urls) + public function purgeUrls(array $urls): bool { - if (strpos($this->domain, 'http') === false) { + if (!str_contains($this->domain, 'http')) { throw new \InvalidArgumentException("'domain' is not configured for fastly driver"); } - if (strpos($this->domain, 'http') !== 0) { + if (!str_starts_with($this->domain, 'http')) { throw new \InvalidArgumentException("'domain' must include the protocol, e.g. http://www.foo.com"); } @@ -96,7 +96,7 @@ public function purgeUrls(array $urls) * * @return bool */ - public function purgeAll() + public function purgeAll(): bool { return $this->sendRequest('POST', 'purge_all'); } @@ -111,7 +111,7 @@ public function purgeAll() * @return bool * @throws \ostark\upper\exceptions\FastlyApiException */ - protected function sendRequest(string $method = 'PURGE', string $uri, array $headers = []) + protected function sendRequest(string $method = 'PURGE', string $uri, array $headers = []): bool { $client = new Client([ 'base_uri' => self::API_ENDPOINT, @@ -130,7 +130,9 @@ protected function sendRequest(string $method = 'PURGE', string $uri, array $hea try { - $client->request($method, $uri); + $response = $client->request($method, $uri); + $body = $response->getBody(); + $contents = $body->getContents(); } catch (BadResponseException $e) { diff --git a/src/drivers/Keycdn.php b/src/drivers/Keycdn.php index 1ff8b45..ff5b47c 100644 --- a/src/drivers/Keycdn.php +++ b/src/drivers/Keycdn.php @@ -16,11 +16,11 @@ class Keycdn extends AbstractPurger implements CachePurgeInterface */ const API_ENDPOINT = 'https://api.keycdn.com/'; - public $apiKey; + public string $apiKey; - public $zoneId; + public string $zoneId; - public $zoneUrl; + public string $zoneUrl; /** @@ -28,7 +28,7 @@ class Keycdn extends AbstractPurger implements CachePurgeInterface * * @return bool */ - public function purgeTag(string $tag) + public function purgeTag(string $tag): int { return $this->sendRequest('DELETE', 'purgetag', [ 'tags' => [$tag] @@ -41,7 +41,7 @@ public function purgeTag(string $tag) * * @return bool */ - public function purgeUrls(array $urls) + public function purgeUrls(array $urls): int { // prefix urls $zoneUrls = array_map(function ($url) { @@ -58,7 +58,7 @@ public function purgeUrls(array $urls) /** * @return bool */ - public function purgeAll() + public function purgeAll(): int { return $this->sendRequest('GET', 'purge', []); } @@ -72,7 +72,7 @@ public function purgeAll() * @return bool * @throws \ostark\upper\exceptions\KeycdnApiException */ - protected function sendRequest($method = 'DELETE', string $type, array $params = []) + protected function sendRequest($method = 'DELETE', string $type, array $params = []): int { $token = base64_encode("{$this->apiKey}:"); $client = new Client([ diff --git a/src/drivers/Varnish.php b/src/drivers/Varnish.php index b9da0ec..08d181a 100644 --- a/src/drivers/Varnish.php +++ b/src/drivers/Varnish.php @@ -14,12 +14,12 @@ class Varnish extends AbstractPurger implements CachePurgeInterface /** * @var string */ - public $purgeHeaderName; + public string $purgeHeaderName; /** * @var string */ - public $purgeUrl; + public string $purgeUrl; /** * @var array @@ -29,7 +29,7 @@ class Varnish extends AbstractPurger implements CachePurgeInterface /** * @param string $tag */ - public function purgeTag(string $tag) + public function purgeTag(string $tag): int { if ($this->useLocalTags) { return $this->purgeUrlsByTag($tag); @@ -46,7 +46,7 @@ public function purgeTag(string $tag) * * @return bool */ - public function purgeUrls(array $urls) + public function purgeUrls(array $urls): int { foreach ($urls as $url) { $success = $this->sendPurgeRequest([ @@ -74,7 +74,7 @@ public function purgeUrls(array $urls) * * @return bool */ - public function purgeAll() + public function purgeAll(): int { return $this->sendPurgeRequest([ 'headers' => $this->headers @@ -82,7 +82,7 @@ public function purgeAll() } - protected function sendPurgeRequest(array $options = [], $method = 'PURGE') + protected function sendPurgeRequest(array $options = [], $method = 'PURGE'): int { $success = true; $purgeUrls = explode(',', $this->purgeUrl); diff --git a/src/events/CacheResponseEvent.php b/src/events/CacheResponseEvent.php index 4c56501..c65ceb1 100644 --- a/src/events/CacheResponseEvent.php +++ b/src/events/CacheResponseEvent.php @@ -12,26 +12,26 @@ class CacheResponseEvent extends Event /** * @var array Array of tags */ - public $tags = []; + public array $tags = []; /** * @var string */ - public $requestUrl; + public string $requestUrl; /** * @var int Cache TTL in seconds */ - public $maxAge = 0; + public int $maxAge = 0; /** * @var string */ - public $output; + public string $output; /** * @var array Array of headers */ - public $headers = []; + public array $headers = []; } diff --git a/src/events/PurgeEvent.php b/src/events/PurgeEvent.php index 499fcc3..b0281ef 100644 --- a/src/events/PurgeEvent.php +++ b/src/events/PurgeEvent.php @@ -15,6 +15,6 @@ class PurgeEvent extends Event /** * @var string tag */ - public $tag; + public string $tag; } diff --git a/src/exceptions/CloudflareApiException.php b/src/exceptions/CloudflareApiException.php index bf31518..3e5f768 100644 --- a/src/exceptions/CloudflareApiException.php +++ b/src/exceptions/CloudflareApiException.php @@ -16,7 +16,7 @@ public function __construct(string $message = "", int $code = 0, \Throwable $pre * * @return static */ - public static function create(RequestInterface $request, ResponseInterface $response = null) + public static function create(RequestInterface $request, ResponseInterface $response = null): static { $uri = $request->getUri(); diff --git a/src/exceptions/FastlyApiException.php b/src/exceptions/FastlyApiException.php index 5a1c9e1..4573881 100644 --- a/src/exceptions/FastlyApiException.php +++ b/src/exceptions/FastlyApiException.php @@ -16,7 +16,7 @@ public function __construct(string $message = "", int $code = 0, \Throwable $pre * * @return static */ - public static function create(RequestInterface $request, ResponseInterface $response = null) + public static function create(RequestInterface $request, ResponseInterface $response = null): static { $uri = $request->getUri(); diff --git a/src/exceptions/KeycdnApiException.php b/src/exceptions/KeycdnApiException.php index c5c1f7f..5459790 100644 --- a/src/exceptions/KeycdnApiException.php +++ b/src/exceptions/KeycdnApiException.php @@ -16,7 +16,7 @@ public function __construct(string $message = "", int $code = 0, \Throwable $pre * * @return static */ - public static function create(RequestInterface $request, ResponseInterface $response = null) + public static function create(RequestInterface $request, ResponseInterface $response = null): static { $uri = $request->getUri(); diff --git a/src/jobs/PurgeCacheJob.php b/src/jobs/PurgeCacheJob.php index 7210177..39971d9 100644 --- a/src/jobs/PurgeCacheJob.php +++ b/src/jobs/PurgeCacheJob.php @@ -14,15 +14,15 @@ class PurgeCacheJob extends BaseJob /** * @var string tag */ - public $tag; + public string $tag; /** * @inheritdoc */ - public function execute($queue) + public function execute($queue): void { - if (!$this->tag) { - return false; + if (!$this->tag ?? true) { + return; } // Get registered purger diff --git a/src/models/Settings.php b/src/models/Settings.php index 047ced7..ff346b4 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -1,4 +1,6 @@ -drivers[$this->driver]['tagHeaderName']; } @@ -95,7 +97,7 @@ public function getTagHeaderName() /** * @return string */ - public function getHeaderTagDelimiter() + public function getHeaderTagDelimiter(): string { return $this->drivers[$this->driver]['tagHeaderDelimiter'] ?? ' '; } @@ -107,7 +109,7 @@ public function getHeaderTagDelimiter() * * @return string */ - public function getKeyPrefix() + public function getKeyPrefix(): string { if (!$this->keyPrefix) { return ''; @@ -120,7 +122,7 @@ public function getKeyPrefix() /** * @return array */ - public function getNoCacheElements() + public function getNoCacheElements(): array { return ['craft\elements\User', 'craft\elements\MatrixBlock', 'verbb\supertable\elements\SuperTableBlockElement']; } @@ -130,7 +132,7 @@ public function getNoCacheElements() * * @return bool */ - public function isCachableElement(string $class) + public function isCachableElement(string $class): bool { return in_array($class, $this->getNoCacheElements()) ? false : true; } From 3f2c1103536880d2a07603ec3d326d1a31d7219a Mon Sep 17 00:00:00 2001 From: John Lennard Date: Thu, 2 Feb 2023 14:49:52 +1300 Subject: [PATCH 2/2] update default config --- src/config.example.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/config.example.php b/src/config.example.php index 6cdb857..ed8df2c 100644 --- a/src/config.example.php +++ b/src/config.example.php @@ -3,11 +3,12 @@ * Don't edit the config.example.php. * Instead modify the projects/config/upper.php and use ENV VARS */ +use craft\helpers\App; return [ // Which driver? - 'driver' => getenv('UPPER_DRIVER') ?: 'dummy', + 'driver' => App::env('UPPER_DRIVER') ?: 'dummy', // Default for Cache-control s-maxage 'defaultMaxAge' => 3600 * 24 * 7, @@ -20,7 +21,7 @@ // same cache store for several Craft installations. // Keep it nice and short for the sake of readability when debugging. // 1-8 characters, special chars get removed - 'keyPrefix' => getenv('UPPER_KEY_PREFIX') ?: '', + 'keyPrefix' => App::env('UPPER_KEY_PREFIX') ?: '', // Optional maximum length for the cache tag header. Setting this higher will // allow Upper to return more tags in the header. However, it will also require @@ -36,38 +37,38 @@ 'varnish' => [ 'tagHeaderName' => 'XKEY', 'purgeHeaderName' => 'XKEY-PURGE', - 'purgeUrl' => getenv('VARNISH_URL') ?: 'http://127.0.0.1:80/', - 'headers' => getenv('VARNISH_HOST') ? ['Host' => getenv('VARNISH_HOST')] : [], + 'purgeUrl' => App::env('VARNISH_URL') ?: 'http://127.0.0.1:80/', + 'headers' => App::env('VARNISH_HOST') ? ['Host' => App::env('VARNISH_HOST')] : [], 'softPurge' => false, ], // Fastly config 'fastly' => [ 'tagHeaderName' => 'Surrogate-Key', - 'serviceId' => getenv('FASTLY_SERVICE_ID'), - 'apiToken' => getenv('FASTLY_API_TOKEN'), - 'domain' => getenv('FASTLY_DOMAIN'), + 'serviceId' => App::env('FASTLY_SERVICE_ID'), + 'apiToken' => App::env('FASTLY_API_TOKEN'), + 'domain' => App::env('FASTLY_DOMAIN'), 'softPurge' => false ], // KeyCDN config 'keycdn' => [ 'tagHeaderName' => 'Cache-Tag', - 'apiKey' => getenv('KEYCDN_API_KEY'), - 'zoneId' => getenv('KEYCDN_ZONE_ID'), - 'zoneUrl' => getenv('KEYCDN_ZONE_URL') + 'apiKey' => App::env('KEYCDN_API_KEY'), + 'zoneId' => App::env('KEYCDN_ZONE_ID'), + 'zoneUrl' => App::env('KEYCDN_ZONE_URL') ], // CloudFlare config 'cloudflare' => [ 'tagHeaderName' => 'Cache-Tag', 'tagHeaderDelimiter' => ',', - 'apiToken' => getenv('CLOUDFLARE_API_TOKEN'), - 'zoneId' => getenv('CLOUDFLARE_ZONE_ID'), - 'domain' => getenv('CLOUDFLARE_DOMAIN'), + 'apiToken' => App::env('CLOUDFLARE_API_TOKEN'), + 'zoneId' => App::env('CLOUDFLARE_ZONE_ID'), + 'domain' => App::env('CLOUDFLARE_DOMAIN'), // deprecated, do not use for new installs - 'apiKey' => getenv('CLOUDFLARE_API_KEY'), - 'apiEmail' => getenv('CLOUDFLARE_API_EMAIL'), + 'apiKey' => App::env('CLOUDFLARE_API_KEY'), + 'apiEmail' => App::env('CLOUDFLARE_API_EMAIL'), ], // Dummy driver (default)