14four/laravel-cloudfront
Composer 安装命令:
composer require 14four/laravel-cloudfront
包简介
Monitor CloudFront and switch origins based on datetime.
README 文档
README
The CloudFront manager will switch which origin is being used for a CloudFront origin.
[toc]
Purpose
The purpose of this package is to automatically switch origins when particular times are passed.
This allows us to host static files in S3 buckets and switch which bucket is used at particular times.
Installation
Add to Composer
composer require 14four/laravel-cloudfront
Publish Config file
php artisan vendor:publish --provider="CloudFrontManger\CloudFrontServiceProvider" --tag="config"
Update Configuration
ID
Set the CloudFront id that you'll be targeting... suggest using env() so that you can overwrite this for stage and production.
EXAMPLE
'id' => env('CLOUDFRONT_ID', 'productionid'),
CREDENTIALS
These will be the credentials that you will be using to access CloudFront. Make sure that you are setting providing credentials that can read and write to CloudFront.
Set these in your .env so you don't compromise your security
EXAMPLE
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
Origins
Set Origins in the configuration. These need to match the Origin ID from the CloudFront Distribution Your Targeting.
EXAMPLE
'origins' => [
'blank' => env('CLOUDFRONT_BLANK', 'origin-id'),
'comingSoon' => env('CLOUDFRONT_COMINGSOON', 's3-coming-soon-bucket'),
'live' => env('CLOUDFRONT_LIVE', 's3-live-bucket'),
'over' => env('CLOUDFRONT_OVER', 's3-over-bucket'),
],
Behaviors
Map your behaviors to dates and the origin that should be live. You can switch multiple behaviors (default is provided).
Each behaviors will be checked based on the last date found that has passed.
EXAMPLE
'behaviors' => [
'DefaultCacheBehavior' => [
[
'date' => env('CLOUDFRONT_PRE_DATE', '2019-08-01 00:00:00'),
'origin' => 'blank',
],
[
'date' => env('CLOUDFRONT_COMING_DATE', '2019-08-02 00:00:00'),
'origin' => 'comingSoon',
],
[
'date' => env('CLOUDFRONT_LIVE_DATE', '2019-09-02 12:00:00'),
'origin' => 'live',
],
[
'date' => env('CLOUDFRONT_OVER_DATE', '2019-11-20 23:59:59'),
'origin' => 'over',
],
],
],
Add to Scheduler
In the app/Console/Kernel.php file add the cloudfront:check command
protected function schedule(Schedule $schedule)
{
$schedule
->command('cloudfront:check')
->everyMinute();
}
14four/laravel-cloudfront 适用场景与选型建议
14four/laravel-cloudfront 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 795 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 09 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 14four/laravel-cloudfront 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 14four/laravel-cloudfront 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 795
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-17