handmadeweb/statamic-cloudflare
Composer 安装命令:
composer require handmadeweb/statamic-cloudflare
包简介
README 文档
README
Cloudflare integration for Statamic with CLI, static caching integration and control panel integration.
Inspired by sebdesign/artisan-cloudflare
Requirements
- Statamic 4.0.0 or higher
Installation
You can install the package via composer:
composer require handmadeweb/statamic-cloudflare
Copy the package config to your local config with the publish command:
php artisan vendor:publish --provider="HandmadeWeb\StatamicCloudflare\ServiceProvider"
Then add your cloudflare details to your .env file.
CLOUDFLARE_KEY= CLOUDFLARE_EMAIL=
or
CLOUDFLARE_TOKEN=
Note that CLOUDFLARE_KEY will be used instead of CLOUDFLARE_TOKEN in the event that they are both set. KEY is the global api key with all possible permissions and TOKEN is a generated Api KEY/TOKEN which has specific permissions enabled/disabled.
And configure your zones, If you only need to specify a single zone, then you can add it to your .env
CLOUDFLARE_ZONE_DOMAIN= CLOUDFLARE_ZONE_ID=
Otherwise you can specify multiple zones in your statamic-cloudflare.php
/* * Array of zones. * * Each zone must have its domain as the key. The value should be your zoneId. * * you can find your zoneId under 'Account Home > site > Api'. * * E.g. * * 'example.com' => '023e105f4ecef8ad9ca31a8372d0c353' */ 'zones' => [ // env('CLOUDFLARE_ZONE_DOMAIN', null) => env('CLOUDFLARE_ZONE_ID', null), ],
By default all purge actions except the Cli commands will be queued with your default queue.
This can be changed in the configuration.
/* * Should purges be processed in a queue? * CLI commands will always run on request. */ 'queued' => true,
Usage
Cli
You can purge everything via the following commands.
php artisan cloudflare:cache:purge:everything
php please cloudflare:cache:purge:everything
Static Caching
If you want to use statamic-cloudflare as a static cache strategy then you will need to manually register the cacher in the register method of your App\Providers\AppServiceProvider class.
/** * Register any application services. * * @return void */ public function register() { \HandmadeWeb\StatamicCloudflare\Cloudflare::registerCacher(); }
Then update your static_cache config.
'strategies' => [ 'half' => [ 'driver' => 'application', 'expiry' => null, ], 'full' => [ 'driver' => 'file', 'path' => public_path('static'), 'lock_hold_length' => 0, ], 'cloudflare' => [ 'driver' => 'cloudflare', 'strategy' => 'null', ], ],
Then update the static_cache strategy at the top of the configuration to:
'strategy' => 'cloudflare',
Currently the Cloudflare integration is only used for purging, If you would like to use another caching strategy in combination with this caching strategy, then you are free to do that.
This can be done by updating the strategy section within the cloudflare strategy, below is an example where we will be caching the application using the half measure
'cloudflare' => [ 'driver' => 'cloudflare', 'strategy' => 'half', ],
In theory, you should be able to use any caching strategy here, such as the full measure or any other first or third party strategies, statamic-cloudfare will simply pass requests to the defined strategy and will just hook into the purge actions to also purge the page in Cloudflare.
Control Panel
Events
statamic-cloudflare will listen to the Statamic\Events\EntrySaved, Statamic\Events\EntryDeleted, Statamic\Events\TermSaved and Statamic\Events\TermDeleted events and will trigger a pruge for the url.
These events will be ignored if you have configured the static cache to be a strategy that uses the cloudflare driver, as the driver will instead handle the needed purging actions.
Utility
statamic-cloudflare will add a utility to your Statamic CP.
route: /cp/utilities/cloudflare
This will be available to Super Users and Users who have the Cloudflare Manager permission.
You can purge everything quickly from here.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
handmadeweb/statamic-cloudflare 适用场景与选型建议
handmadeweb/statamic-cloudflare 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.45k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2021 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cloudflare」 「statamic」 「statamic-addon」 「statamic-plugin」 「statamic-cache」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 handmadeweb/statamic-cloudflare 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 handmadeweb/statamic-cloudflare 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 handmadeweb/statamic-cloudflare 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generate realfavicon from your Statamic control panel
Symfony bundle for Cloudflare integration: trusted proxies, real client IP detection, forwarded headers.
Statamic Fine Seo addon
A powerful, efficient analytics solution for Statamic with real-time tracking, caching, and comprehensive dashboard visualization.
Cloudflare Middleware For Guzzle
统计信息
- 总下载量: 5.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-27