rc4347/cloudfront-signer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rc4347/cloudfront-signer

最新稳定版本:0.0.4

Composer 安装命令:

composer require rc4347/cloudfront-signer

包简介

README 文档

README

Latest Stable Version Total Downloads

This is a simple PHP service for making it easy include the official AWS SDK for PHP in your PHP applications.

It's helps you to sign your files or resources.

Jump To:

Getting Started

Installation

The PHP Service can be installed via Composer by requiring the rc4347/cloudfront-signer package in your project's composer.json.

{
    "require": {
        "rc4347/cloudfront-signer": "^0.0.4"
    }
}

Usage

use RC4347\CloudFrontSigner\credentials\AccessConfig;
use RC4347\CloudFrontSigner\credentials\ClientConfig;
use RC4347\CloudFrontSigner\credentials\ExpireConfig;
use RC4347\CloudFrontSigner\SignedUrlService;

# configuration
$client = new ClientConfig('latest', 'default', '<YOUR_S3_REGION>');
$expire = time() + 300; # returns 5 minutes
$access = new AccessConfig('<YOUR_PRIVATE_KEY>', '<YOUR_S3_KEY_PAIR_ID>'); # private key can get file or string 
$resourceKey = 'https://<YOUR_ID>.cloudfront.net/example/example.png';
$config = new ExpireConfig($resourceKey, $expire);
# Execution
/**
* @returns string "https://<YOUR_ID>.cloudfront.net/example/example.png?Expires=<EXPIRES>&Signature=<SIGNATURE>&Key-Pair-Id=<YOUR_S3_KEY_PAIR_ID>"
 */
$urlService = new SignedUrlService($config, $client, $access);
return $urlService->run();
/**
 * if policy param is empty it will be get default policy.
* @returns array|string [
        "CloudFront-Policy": <GENERATED_POLICY>,
        "CloudFront-Signature": <SIGNATURE>,
        "CloudFront-Key-Pair-Id": <YOUR_S3_KEY_PAIR_ID>
    ]
 */
$policy = <<<POLICY
{
    "Statement": [
        {
            "Resource": "{$this->config->resourceKey}",
            "Condition": {
                "DateLessThan": {"AWS:EpochTime": {$this->config->expires}}
            }
        }
    ]
}
POLICY;

$cookieService = new SignedCookieService($config, $client, $access, $policy) # policy is optional
return $cookieService->run();

Resources

For more information:

统计信息

  • 总下载量: 6.7k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-12-01