PHPackages                             clippings/env-backup - 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. clippings/env-backup

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

clippings/env-backup
====================

Backup/restore environment variables: globals, static vars, configs

0.2.5(12y ago)09262BSD-3-ClausePHP

Since Mar 13Pushed 12y ago27 watchersCompare

[ Source](https://github.com/clippings/env-backup)[ Packagist](https://packagist.org/packages/clippings/env-backup)[ RSS](/packages/clippings-env-backup/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (7)DependenciesVersions (8)Used By (2)

Env Backup
==========

[](#env-backup)

[![Build Status](https://camo.githubusercontent.com/e4b4101c9d6066f4d676813df8045d7d912983ce9a2a498f693d0a97bc258638/68747470733a2f2f7472617669732d63692e6f72672f636c697070696e67732f656e762d6261636b75702e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/clippings/env-backup)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/58c47f2cb5b836f8d62646c25036d1ad81d138830668d3831483aa65fdbe2ba0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636c697070696e67732f656e762d6261636b75702f6261646765732f7175616c6974792d73636f72652e706e673f733d35653132613965363135343439653262363363633562616533316663393266366262393737636134)](https://scrutinizer-ci.com/g/clippings/env-backup/)[![Code Coverage](https://camo.githubusercontent.com/bdb0dfca5ece799eea8af613259a5e4c2c4272f4392ac4abd5d906ca711aa650/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636c697070696e67732f656e762d6261636b75702f6261646765732f636f7665726167652e706e673f733d62663462653838633931303237313135306163633566623063653262643164303538356561353234)](https://scrutinizer-ci.com/g/clippings/env-backup/)[![Latest Stable Version](https://camo.githubusercontent.com/b4513a43befe6e1f9d1707dabd831f629b96d8331fd5431a871959806fb77cea/68747470733a2f2f706f7365722e707567782e6f72672f636c697070696e67732f656e762d6261636b75702f762f737461626c652e706e67)](https://packagist.org/packages/clippings/env-backup)

Backup/restore environment variables: globals and static vars. This is very useful for initializing environment for a test. Keep the current state of the environment from interfering with other tests.

You can add "Parameters" to the environment, each "applying" and "restoring" a specific super global or static property of a class, you can even keep a precice state of the filesystem.

- `GlobalParam` - used for setting / restoring '\_POST', '\_GET', '\_FILES', '\_SERVER', '\_COOKIE' and '\_SESSION'
- `ServerParam` - used specifically for '\_SERVER' super global so you can set / restore only some of its contents, e.g. REMOTE\_HOST', 'CLIENT\_IP ...
- `StaticParam` - used for setting / restoring static properties of classes, it can handle protected and private ones too.
- `FileParam` - used for setting / restoring files and their contents. Ensures a certain file and its content are present, and restore previous state
- `DirectoryParam` - used for setting / restoring a whole dir with all of its contents. Ensures a certain dir and its content are present, and restore previous state

Example:

```
use CL\EnvBackup\Env;
use CL\EnvBackup\GlobalParam;
use CL\EnvBackup\ServerParam;
use CL\EnvBackup\StaticParam;

$env = new Env(array(
    new GlobalParam('_POST', array('new post name' => 'val')),
    new ServerParam('REMOTE_ADDR', '1.1.1.1'),
    new StaticParam('MyClass', 'private_var', 10)
    new FileParam('/path/to/file', 'file content')
    new DirectoryParam('/path/to/dir', array(
        'file1.txt' => 'file contents',
        'inner_dir' => array(
            'inner_file1.csv' => 'a, b',
            'inner_file2.txt' => 'test',
        )
    ))
));

$env->apply();

// Do some stuff that changes / uses these variables
// ...

$env->restore();
```

ServerParam in CLI
------------------

[](#serverparam-in-cli)

In CLI environment, $\_SERVER variables are very different than if the script is run by apache or cgi. If you want to use env-backup in such an environment, you can pass ServerParam::CLI like this:

```
$env = new Env(array(
    new ServerParam('HOME', '/test/home', ServerParam::CLI),
    new ServerParam('argc', 4, ServerParam::CLI),
));
```

License
-------

[](#license)

Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin as part of [clippings.com](http://clippings.com)

Under BSD-3-Clause license, read LICENSE file.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% 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

7

Last Release

4444d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4113307?v=4)[Danail Kyosev](/maintainers/dkyosev)[@dkyosev](https://github.com/dkyosev)

![](https://avatars.githubusercontent.com/u/7592650?v=4)[Evstati Zarkov](/maintainers/EZarkov)[@EZarkov](https://github.com/EZarkov)

---

Top Contributors

[![ivank](https://avatars.githubusercontent.com/u/4976?v=4)](https://github.com/ivank "ivank (24 commits)")[![hkdobrev](https://avatars.githubusercontent.com/u/506129?v=4)](https://github.com/hkdobrev "hkdobrev (1 commits)")

### Embed Badge

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

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

###  Alternatives

[aura/html

Provides HTML escapers and helpers, including form input helpers.

52277.4k22](/packages/aura-html)[bubbstore/correios

Biblioteca que faz cálculo de frete, rastreamento de objetos e consulta de CEP diretamente do Webservice dos Correios.

2591.6k](/packages/bubbstore-correios)[olivestudio/craft-olivemenus

A powerful menus plugin for Craft 4 built for the need of simplicity and flexibility

3919.0k1](/packages/olivestudio-craft-olivemenus)[indieweb/representative-h-card

1624.7k5](/packages/indieweb-representative-h-card)

PHPackages © 2026

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