承接 tixelrocks/long-env 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tixelrocks/long-env

最新稳定版本:0.5

Composer 安装命令:

composer require tixelrocks/long-env

包简介

A helper function that adds support for long environment variables (eg for AWS)

README 文档

README

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

An env() alternative that works with long multi-line environment variables in places where it's not possible to do so natively - eg. AWS Elastic Beanstalk

Imagine you want to run Laravel Passport in AWS so you need to pass your private key as a PASSPORT_PRIVATE_KEY environment variable but hey 1) AWS doesn't allow multi-line environment variables 2) AWS has a limit of 4096 character per environment variable.

So you end up getting an annoying error like this:

Service:AmazonCloudFormation, Message:Template format error: Parameter 'EnvironmentVariables' default value '[****]' length is greater than 4096.

Solution

Our solution is simple, go to config/passport.php and replace

<?php 
return [
    'private_key' => env('PASSPORT_PRIVATE_KEY')
];

with:

return [
    'private_key' => long_env('PASSPORT_PRIVATE_KEY')
];

And now pass your long variable as numbered chunks instead of one super long string:

PASSPORT_PRIVATE_KEY1=
PASSPORT_PRIVATE_KEY2=
PASSPORT_PRIVATE_KEY3=
# and so on

The long_env() function will magically combine them together for you. If you need help making the chunks, just use the long_env_prepare() function provided with this package:

<?php
  json_encode(long_env_prepare('KEY', 'SUPER LONG STRING'), JSON_PRETTY_PRINT);
{
    "KEY1": "-----BEGIN PRIVATE K",
    "KEY2": "EY-----\ndasokd aoskd",
    "KEY3": "o aksdoaskd oaskdo a"
}

That's it - copy & paste these one by one into your dashboard (eg. AWS Elastic Beanstalk's Configuration tab)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固