madeiramadeirabr/hagrid 问题修复 & 功能扩展

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

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

madeiramadeirabr/hagrid

Composer 安装命令:

composer require madeiramadeirabr/hagrid

包简介

Simplified integration with aws secrets manager.

README 文档

README

Simplified integration with AWS Secrets Manager.

Getting Started

The purpose of this package is to simplify integration with AWS Secrets Manager, providing an easy way to retrive stored data.

All helpers considers that you have an role in EC2. This role must be allowed to access secrets manager. If EC2 doesn't has role to access SM, you need to create you own helpers using aws id and key to authenticate. All methods are explained here.

Prerequisites

* PHP >= 7.1;
* JSON PHP Extension;
* Composer

Installing

Download the package using composer.

composer require madeiramadeirabr/hagrid

Basic Usage

Basic integration can be accomplished in three ways.

First Method: Raw Data Retrive

This way retrive the raw json from secrets manager. This is useful if you application need to manipulate environment variables before save it.

To do that, call secrets manager helper, as in the example below:

$rawData = retrive_secrets($secretId);

The response will be something like that:

{
    "APP_NAME": "My App Name", 
    "APP_ENV": "production"
}

Second Method: Create .env File

This method will verify if .env file exists, if it don't, it will be created from data retrived from secrets manager.

$fileCreated = create_env_file($directory, $secretId);

The response will be TRUE, if the file was created, and FALSE, if don't.

Third Method: Save data on environment

This method will read data from secrets manager and save using putenv.

add_env_vars($secretId);

This method doesn't have any response.

Use without helpers

If EC2 doesn't have role, you can instatiate SecretsManager and pass the the credentials to authenticate.

First Method

Instantiating the SecretsManager class and calling the setters.

$secretsManager = new SecretsManager();

$secretsManager->setSecretId($secretId)
    ->setRegion($awsRegion)
    ->setId($myAwsId)
    ->setKey($myAwsKey);

Second Method

Instantiating the SecretsManager with AWS credentials.

$secretsManager = new SecretsManager($secretId, $awsRegion, $myAwsId, $myAwsKey);

And Finally

After using either of the two methods above, call the method that performs data recovery.

$secretValue = $secretsManager->getSecretValue();

Response

The response of the method 'getSecretValue' will be something like this.

{
    "APP_NAME": "My App Name", 
    "APP_ENV": "production"
}

Authors

See also the list of contributors who participated in this project.

madeiramadeirabr/hagrid 适用场景与选型建议

madeiramadeirabr/hagrid 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.59k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 11 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 madeiramadeirabr/hagrid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 madeiramadeirabr/hagrid 我们能提供哪些服务?
定制开发 / 二次开发

基于 madeiramadeirabr/hagrid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.59k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 26
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-25