PHPackages                             bckp/environment-adapter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bckp/environment-adapter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bckp/environment-adapter
========================

Simple class for getting environment in proper type with fallback

v1.0.0(2y ago)05MITPHPPHP &gt;= 8.0

Since Dec 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bckp/environment-adapter)[ Packagist](https://packagist.org/packages/bckp/environment-adapter)[ RSS](/packages/bckp-environment-adapter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

[![](https://camo.githubusercontent.com/44cfadb42ca0dd438b07e24d2aded6b8e45751e6c50d6b78ce5231b73d996cc4/68747470733a2f2f686561746261646765722e6e6f772e73682f6769746875622f726561646d652f62636b702f656e7669726f6e6d656e742d616461707465722f)](https://camo.githubusercontent.com/44cfadb42ca0dd438b07e24d2aded6b8e45751e6c50d6b78ce5231b73d996cc4/68747470733a2f2f686561746261646765722e6e6f772e73682f6769746875622f726561646d652f62636b702f656e7669726f6e6d656e742d616461707465722f)

Bckp/Environment-adapter
========================

[](#bckpenvironment-adapter)

Adapter for Nette so you can use \*.env config files.

[![Coverage Status](https://camo.githubusercontent.com/8ae0d16b63352796a0776f8c91a0b80452a340abcccaddc9874120017a75ac1f/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f62636b702f656e7669726f6e6d656e742d616461707465722f6d6173746572)](https://coveralls.io/github/bckp/environment-adapter?branch=master)[![Build Status](https://camo.githubusercontent.com/c682fb2c4ad81681027b6f3db3f812cbe885de3fbfd436692dffd774ac051588/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62636b702f656e7669726f6e6d656e742d616461707465722f54657374732f6d6173746572)](https://github.com/bckp/environment-adapter/actions)[![Downloads this Month](https://camo.githubusercontent.com/e21293c843db31c8be4aca6961f9dd1b962432c66480f81d27f9666f1dff2c1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f62636b702f656e7669726f6e6d656e742d616461707465722e737667)](https://packagist.org/packages/bckp/environment-adapter)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5d23a7d440e972c2d9b59bfb548d71489ad741975f1e59b4ff26eb0c33689c1c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f62636b702f656e7669726f6e6d656e742d616461707465722f6d6173746572)](https://scrutinizer-ci.com/g/bckp/environment-adapter/?branch=master)[![Latest stable](https://camo.githubusercontent.com/3e3277091a7cf9209f15bbd90143d0fb74f5bba19c75b461fa6b982058d7dd34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62636b702f656e7669726f6e6d656e742d616461707465722e737667)](https://packagist.org/packages/bckp/environment-adapter)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/bckp/environment-adapter/blob/master/license.md)

Installation
------------

[](#installation)

The best way to install Bckp/Environment-adapter is using [Composer](http://getcomposer.org/):

```
$ composer require bckp/environment-adapter
```

Development
-----------

[](#development)

This package is currently maintaining by these authors.

[![](https://avatars.githubusercontent.com/u/179652?v=4&s=80)](https://github.com/bckp)

How to use
----------

[](#how-to-use)

For use this adapter, you need to use Bckp/Configurator instead of Nette one. It will autoregister ENV extension support. After that, you can simply link `some-name.env` file and nette will inject env variables into %env%. The expected syntax is name\_of\_env\_variable: ::{string|int|float|bool}(default: {string}, hidden: {true|false}) name\_of\_array\_variable: ::array(separator: {string}, hidden: {true|false}, cast: {int|float|bool|string})

first entry is name of ENV variable, this will add `%env.name_of_env_variable%` to the parameters and get value using `getenv('NAME_OF_ENV_VARIABLE');`next is `::` that will tell adapter, we are working with entity, this is just shortcut to force nette get arguments using internal mechanism. after that, we have `cast` part, this tells adapter, what type of variable he should cast to, usefull as env know only strings, with this, you can have INTs, FLOATs, BOOLs and even ARRAY of INT, FLOAT, STRING, BOOL.

attributes inside

```
default: that is fallback, if no value is found using getenv.
hidden: if variable must remain secret, or we can burn it into generated container file (if we have password, we do not want to have it stored in PHP file, but kept it in ENV only)
cast: only for Array, cast values to specific type
separator: only for Array, used for explode

```

if you keep order of arguments same as Environment class expect, you can omit their names.

### Example file

[](#example-file)

```
service_user: ::string(secret_user)
service_password: ::string(secret_password, true)
service_port: ::int(1234)
service_nonstring: ::nonstring(1234)
service_active: ::bool(\'false\')
service_array: ::array(cast: int)

```

with .env

```
SERVICE_USER=someuser
SERVICE_PASSWORD=supersecret
SERVICE_ARRAY=1|2|3|4

```

will be translated to if none ENV

```
[
	'service_user' => 'someuser',
	'service_password' => Bckp\Environment::string('SERVICE_PASSWORD', 'secret_password'),
	'service_port' => 1234,
	'service_nonstring' => '1234',
	'service_active' => false # notice string false is translated to the boolean correctly
	'service_array' => [1,2,3,4],
]
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

894d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/179652?v=4)[Radovan Kepák](/maintainers/bckp)[@bckp](https://github.com/bckp)

---

Top Contributors

[![bckp](https://avatars.githubusercontent.com/u/179652?v=4)](https://github.com/bckp "bckp (5 commits)")

###  Code Quality

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bckp-environment-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/bckp-environment-adapter/health.svg)](https://phpackages.com/packages/bckp-environment-adapter)
```

###  Alternatives

[nette/php-generator

🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.

2.2k64.2M576](/packages/nette-php-generator)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[nette/code-checker

✅ Nette CodeChecker: A simple tool to check source code against a set of Nette coding standards.

881.7M6](/packages/nette-code-checker)[contributte/di

Extra contrib to nette/di

465.8M18](/packages/contributte-di)[brandembassy/slim-nette-extension

19190.2k](/packages/brandembassy-slim-nette-extension)[bileto/cronner

Simple tool which helps with maintenance of cron tasks.

752.1k](/packages/bileto-cronner)

PHPackages © 2026

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