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

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

ffi/env
=======

PHP FFI Environment

1.0.3(1y ago)561.6k—4.8%110MITPHPPHP ^7.4|^8.0CI failing

Since Nov 3Pushed 1y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (5)Versions (6)Used By (10)

FFI Environment
===============

[](#ffi-environment)

 [![PHP 8.1+](https://camo.githubusercontent.com/e57f2c24ea259ed8f3bff400f42989f975b96dd13c2fe91a17c0b179bd65a598/68747470733a2f2f706f7365722e707567782e6f72672f6666692f656e762f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/env) [![Latest Stable Version](https://camo.githubusercontent.com/8a2eb716e82cfc44cae76a52c4dce55e1305c5538f656de251392137941603d9/68747470733a2f2f706f7365722e707567782e6f72672f6666692f656e762f76657273696f6e3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/env) [![Latest Unstable Version](https://camo.githubusercontent.com/d0a568a31df683ef327489b5f7282c9f9a95b914bc6380fa0ce6238e49d59e97/68747470733a2f2f706f7365722e707567782e6f72672f6666692f656e762f762f756e737461626c653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/env) [![Total Downloads](https://camo.githubusercontent.com/f2123376442e28529986f6b20a6f720c7f2b749ede4aebb906497c99c5ce02e6/68747470733a2f2f706f7365722e707567782e6f72672f6666692f656e762f646f776e6c6f6164733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ffi/env) [![License MIT](https://camo.githubusercontent.com/97883a9053bd76efe6071cfa9dfefa0454361911facdfb88eaa329d25cca0c50/68747470733a2f2f706f7365722e707567782e6f72672f6666692f656e762f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://raw.githubusercontent.com/php-ffi/env/master/LICENSE.md)

 [![](https://github.com/php-ffi/env/workflows/build/badge.svg)](https://github.com/php-ffi/env/actions)

A set of API methods for working with the FFI environment.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4

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

[](#installation)

Library is available as composer repository and can be installed using the following command in a root of your project.

```
$ composer require ffi/env
```

Usage
-----

[](#usage)

### Retrieve FFI Status

[](#retrieve-ffi-status)

```
use FFI\Env\Runtime;

$status = Runtime::getStatus();
```

Status can be be one of:

- `\FFI\Env\Status::NOT_AVAILABLE` - Extension not available.
- `\FFI\Env\Status::DISABLED` - Extension disabled.
- `\FFI\Env\Status::ENABLED` - Extension enabled and available in any environment.
- `\FFI\Env\Status::CLI_ENABLED` - Extension available only in CLI SAPI or using a preload.

### Checking Availability

[](#checking-availability)

```
use FFI\Env\Runtime;

$isAvailable = Runtime::isAvailable();
```

In the case that the environment needs to be checked unambiguously, then you can use `assertAvailable()` method:

```
use FFI\Env\Runtime;

Runtime::assertAvailable();
// Throws an \FFI\Env\Exception\EnvironmentException in case FFI is not available.
```

### Optimization

[](#optimization)

To check the environment, it is recommended to use the `assert` functionality.

```
use FFI\Env\Runtime;
use FFI\Env\Exception\EnvironmentException;

assert(Runtime::assertAvailable());

// Or using your own assertion error message:
assert(Runtime::isAvailable(), EnvironmentException::getErrorMessageFromStatus());
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance49

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity59

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 ~320 days

Total

5

Last Release

375d ago

Major Versions

0.1.0 → 1.0.02021-11-03

PHP version history (2 changes)0.1.0PHP &gt;=7.4

1.0.1PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150420?v=4)[Ruslan Sharipov](/maintainers/Serafim)[@serafim](https://github.com/serafim)

---

Top Contributors

[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (16 commits)")

---

Tags

ffiphpenvironmentenvffi

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[symfony/dotenv

Registers environment variables from a .env file

3.8k226.7M2.3k](/packages/symfony-dotenv)[imliam/laravel-env-set-command

Set a .env file variable from the command line

118352.4k10](/packages/imliam-laravel-env-set-command)[msztorc/laravel-env

Laravel env helper commands

7855.4k](/packages/msztorc-laravel-env)[cekurte/environment

A library to get the values from environment variables and process to php data types

5884.0k7](/packages/cekurte-environment)[mirazmac/dotenvwriter

A PHP library to write values to .env (DotEnv) files

19129.3k7](/packages/mirazmac-dotenvwriter)

PHPackages © 2026

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