New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

tixelrocks/long-env

A helper function that adds support for long environment variables (eg for AWS)
11,519 1
Install
composer require tixelrocks/long-env
Latest Version:0.5
PHP:>=5.5.0
Laravel:5 – 12
License:MIT
Last Updated:Jul 7, 2025
Links: GitHub  ·  Packagist
Maintainer: dusterio

long-env

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)

Related Packages

saas-laravel/laravel-plain-sqs

SQS connector for Laravel that supports custom JSON

69,626 0
sunaoka/laravel-ssm-parameters-loader

Load values from AWS SSM Parameter store into environment variables for Laravel

7,241 2
dev-paynoomo/laravel-plain-sqs

Custom SQS connector for Laravel that supports custom format JSON

4,218 0
dusterio/laravel-plain-sqs

Custom SQS connector for Laravel that supports custom format JSON

2,889,347 134
najamhaq/laravel-plain-sqs

Custom SQS connector for Laravel that supports custom format JSON

19,413 0

Version History

Version Released PHP Laravel License
0.5 >=5.5.0 5.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0 MIT
0.4 >=5.5.0 5.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0 MIT
0.3 >=5.5.0 5.*|^6.0|^7.0|^8.0|^9.0|^10.0 MIT
0.2 >=5.5.0 5.*|^6.0|^7.0|^8.0|^9.0 MIT
0.1 >=5.5.0 5.*|^6.0|^7.0|^8.0 MIT