PHPackages                             justenough/craft-envfield - 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. justenough/craft-envfield

ActiveCraft-plugin

justenough/craft-envfield
=========================

A drop-in replacement for CraftCMS plain text fields with environment variable support, inc autosuggest

1.0.2(4y ago)0151MITPHPPHP ^7.4 | ^8.0

Since Feb 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/justenoughco/craft-envfield)[ Packagist](https://packagist.org/packages/justenough/craft-envfield)[ RSS](/packages/justenough-craft-envfield/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

Env Field plugin for Craft CMS 3.x
==================================

[](#env-field-plugin-for-craft-cms-3x)

What?
-----

[](#what)

Provides a(n almost completely\*) drop-in replacement for Craft's built-in plain text field which has environment variable support, including optional autosuggest.

Why?
----

[](#why)

Sometimes you have values that need to be managed on a per-entry basis, but which need to vary by environment (e.g. ID's in external systems / API's). This field allows you to store those ID's [in environment variables](https://12factor.net/config), and have everything work as expected when moving data between environments.

[![Example #1](resources/img/field-example.png)](resources/img/field-example.png)

[![Example #2](resources/img/field-expanded-example.png)](resources/img/field-expanded-example.png)

\* Multi-line plain text fields aren't supported

Caution
-------

[](#caution)

Environment Variables may contain sensitive information, including passwords and API keys. This plugin was designed with a very specific use-case in mind.

If not used carefully, the fieldtype makes it trivially easy to leak information from Environment Variables into your front end templates. Depending on the value(s) leaked, this could cause Very Bad Things To Happen.

This plugin does it's best not to help you to shoot yourself in the foot by automatically filtering the autosuggested environment variable names to remove common sensitive values that are unlikely to be used as field values in the course of normal usage (see [the config section](#config-settings) below for details), but ultimately you are responsible for your use of this plugin.

Make sure that you...

### Do:

[](#do)

- Use Craft's permissons and user groups to ensure that only admins / editors that know what they're doing can edit fields that use this fieldtype
- Add appropriate instructions / tips to fields (sensible, configurable defaults are provided)
- Use this fieldtype only where it's not possible to reference environment variables statically via config files (`config/general.php` and friends)
- Check the default `excludePattern` suits your environment and adjust it if required
- Use the `includePattern` config option to clearlist environment variable names for use wherever possible

### Don't

[](#dont)

- Be an idiot

How?
----

[](#how)

### Requirements

[](#requirements)

This plugin requires Craft CMS 3.5 or later. It will *probably* work with older versions, but is untested with them.

This plugin requiress PHP 7.4+

### Installation

[](#installation)

```
cd /path/to/project
composer require justenoughco/craft-envfield
./craft plugin/install envfield
```

Then either create a new field or change the type of an existing Plain Text fieldto " Environment Variable-Aware Plain Text". This *should* be safe as all Plain Text field settings are preserved, even if they aren't available when using as an Env Field, but if converting an existing field, test outside of production first.

### Per-field settings

[](#per-field-settings)

In addition to the built-in Plain Text fields settings, this fields allows setting:

- `Warning`: Displayed underneath the field. Defaults to a warning about about leaking sensitive information.

Config settings
---------------

[](#config-settings)

On install a `config/envfield.php` file will be created. You can use that field to adjust the following settings:

```
[
    /*
        Blocklist pattern

        Regex used to preprocess the autosuggest list of all environment variable names to remove sensitive values

        (enabled by default)
    */
    'excludePattern' => '/^\$(CONTENT|DOCUMENT|DB|HTTP|SERVER|REDIS|GPG|SCRIPT|REMOTE|REQUEST|PHP|PHPIZE|PATH|SECURITY|FCGI)_|^\$(GATEWAY_INTERFACE|HOME|PATH|PWD|REMOTE|TERM|USER)$/i',
    /* Clearlist pattern

        Regex used to preprocess the autosuggest list of all environment variable names to allow only specific values / prefixes into the autosuggest list

        (not enabled by default, set `excludePattern` to falsy to use)
    */
    // 'includePattern' => null
]
```

Environment variables that are filtered out will:

- Not appear in the autosuggest list for Environment Variable-Aware Plain Text fields
- Trigger a validation error on save if manually entered into an Environment Variable-Aware Plain Text field

Licence
-------

[](#licence)

MIT

Who?
----

[](#who)

Brought to you by [Just Enough Consulting](https://justenough.co)

Icon by Vectorstall [from The Noun Project](https://thenounproject.com/icon/dollar-4541660/)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

3

Last Release

1543d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a4a6c669cfbf869013a978c80f24947fc5d600c2ca15416d38fdb56a1322457f?d=identicon)[justenough](/maintainers/justenough)

---

Top Contributors

[![tomdavies](https://avatars.githubusercontent.com/u/136308?v=4)](https://github.com/tomdavies "tomdavies (6 commits)")

---

Tags

cmsCraftcraftcmscraft-pluginenv field

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/justenough-craft-envfield/health.svg)

```
[![Health](https://phpackages.com/badges/justenough-craft-envfield/health.svg)](https://phpackages.com/packages/justenough-craft-envfield)
```

###  Alternatives

[verbb/image-resizer

Resize assets when they are uploaded.

127269.1k7](/packages/verbb-image-resizer)[pennebaker/craft-architect

CraftCMS plugin to generate content models from JSON/YAML data.

72148.5k5](/packages/pennebaker-craft-architect)[supercool/buttonbox

A collection of utility field types.

8953.2k1](/packages/supercool-buttonbox)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
