PHPackages                             24hoursmedia/php-env-inject - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. 24hoursmedia/php-env-inject

ActiveLibrary

24hoursmedia/php-env-inject
===========================

Inject and interpolate environment variables into strings. Supports substituting default values for an env var, and escapers/formatters using callbacks. Partially supports POSIX compliant shell syntax.

1.1.1(2y ago)125Apache-2.0PHPPHP &gt;=8.0

Since Nov 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/24HOURSMEDIA/php-env-inject)[ Packagist](https://packagist.org/packages/24hoursmedia/php-env-inject)[ RSS](/packages/24hoursmedia-php-env-inject/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

EnvInject
=========

[](#envinject)

Inject/interpolate environment variables in strings.

- Substitutes raw environment variables in strings
- Supports default values if environment variable is not set
- Supports escaping JSON strings
- Supports a callback to write your own value modifiers / escapers

Security Considerations
-----------------------

[](#security-considerations)

⚠️ As often environment variables on a system may contain sensitive data, especially if you use dotenv, you should NEVER ALLOW USER INPUT into the interpolator.

⚠️ Only interpolate into strings that are under your control and fully trusted!

Install
-------

[](#install)

```
composer require 24hoursmedia/php-env-inject

```

Usage
-----

[](#usage)

### Interpolate env vars in a string

[](#interpolate-env-vars-in-a-string)

```
