PHPackages                             kero/typesafe-env - 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. kero/typesafe-env

ActiveLibrary

kero/typesafe-env
=================

Wrapper around Laravel's Env to support type safety.

0.1.3(1y ago)41521[1 PRs](https://github.com/kingkero/typesafe-env/pulls)MITPHPPHP ^8.1CI passing

Since Oct 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kingkero/typesafe-env)[ Packagist](https://packagist.org/packages/kero/typesafe-env)[ RSS](/packages/kero-typesafe-env/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (8)Versions (10)Used By (0)

Type Safe Env
=============

[](#type-safe-env)

Install via `composer req kero/typesafe-env`

[![GitHub latest tag](https://camo.githubusercontent.com/59b0f18c7293ad0695834c09c1a0bec8d0699af2cf868746e2322c57e1e7b3a6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6b696e676b65726f2f74797065736166652d656e76)](https://camo.githubusercontent.com/59b0f18c7293ad0695834c09c1a0bec8d0699af2cf868746e2322c57e1e7b3a6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6b696e676b65726f2f74797065736166652d656e76) [![codecov](https://camo.githubusercontent.com/2bcc446b796e4c6a6f270c811745b9d2a2418f46b6a4f110355ee6695d891256/68747470733a2f2f636f6465636f762e696f2f67682f6b696e676b65726f2f74797065736166652d656e762f67726170682f62616467652e7376673f746f6b656e3d344541415a5945414e33)](https://codecov.io/gh/kingkero/typesafe-env) [![license: MIT](https://camo.githubusercontent.com/f7bb1873d95c9b3657fabd4b9f48bed98f752e73904e5674db36c4fcb9863de3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b696e676b65726f2f74797065736166652d656e76)](https://camo.githubusercontent.com/f7bb1873d95c9b3657fabd4b9f48bed98f752e73904e5674db36c4fcb9863de3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b696e676b65726f2f74797065736166652d656e76)

Usage
-----

[](#usage)

Assuming the following environment variables

```
API_URL=foo
APP_STRING_OR_NULL=null

APP_DEBUG=true
APP_LOG=false
APP_BOOL_OR_NULL=null

APP_PI=3

APP_BETTER_PI=3.14
```

```
use Kero\TypeSafeEnv\Env;

var_dump(Env::getString('API_URL')); // string(3) "foo"
var_dump(Env::getNullableString('APP_STRING_OR_NULL')); // NULL

var_dump(Env::getBool('APP_DEBUG')); // bool(true)
var_dump(Env::getBool('APP_LOG')); // bool(false)
var_dump(Env::getNullableBool('APP_BOOL_OR_NULL')); // NULL

var_dump(Env::getInt('APP_PI')); // int(3)

var_dump(Env::getFloat('APP_PI')); // float(3.14)
```

❗ Due to Laravel's implementation, both values `null` and `(null)` are treated as `NULL`.

Local Development
-----------------

[](#local-development)

### Code Style

[](#code-style)

Currently using plain **PSR-12** via [Laravel Pint](https://laravel.com/docs/10.x/pint). Apply the code style via

```
make pint
```

### Tests

[](#tests)

Using [Pest](https://pestphp.com/) for testing. Run existing tests via

```
make test
```

❗ Tests are relying on the environment variables defined in *.env.testing*

[Type Coverage](https://pestphp.com/docs/type-coverage) can also be tested via Pest. Current implementation inside *Makefile* is buggy ... (TODO: fix so command in Makefile via Docker can be used)

```
./vendor/bin/pest --type-coverage --min=100
```

### Code Analysis

[](#code-analysis)

[PHPStan](https://phpstan.org/) is configured to check `./src/` and `./tests/` via

```
make analyse
```

### Various

[](#various)

- normalize *composer.json* file via [`ergebnis/composer-normalize`](https://github.com/ergebnis/composer-normalize)

```
composer normalize
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance48

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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 ~90 days

Recently: every ~135 days

Total

7

Last Release

389d ago

### Community

Maintainers

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

---

Top Contributors

[![kingkero](https://avatars.githubusercontent.com/u/2728418?v=4)](https://github.com/kingkero "kingkero (105 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![alexkart](https://avatars.githubusercontent.com/u/8249105?v=4)](https://github.com/alexkart "alexkart (1 commits)")

---

Tags

environmentlaravelphptype-safety

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kero-typesafe-env/health.svg)

```
[![Health](https://phpackages.com/badges/kero-typesafe-env/health.svg)](https://phpackages.com/packages/kero-typesafe-env)
```

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

1.5k1.2M4](/packages/beyondcode-laravel-self-diagnosis)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)

PHPackages © 2026

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