PHPackages                             openbuildings/environment-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. openbuildings/environment-backup

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

openbuildings/environment-backup
================================

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

0.1.2(9y ago)0136.4k10BSD-3-ClausePHP

Since Jul 23Pushed 7y ago10 watchersCompare

[ Source](https://github.com/OpenBuildings/environment-backup)[ Packagist](https://packagist.org/packages/openbuildings/environment-backup)[ RSS](/packages/openbuildings-environment-backup/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (10)

Environment Backup [![Build Status](https://camo.githubusercontent.com/b38e142da60a92e2acced272f96bb2b32ef7c57e52b2e22c804ea3bb5dd28c68/68747470733a2f2f7472617669732d63692e6f72672f4f70656e4275696c64696e67732f656e7669726f6e6d656e742d6261636b75702e706e67)](https://travis-ci.org/OpenBuildings/environment-backup) [![Coverage Status](https://camo.githubusercontent.com/b6400624b28f8b864ce9aac9621fdb3d355e936ab6aa69db814c961d34a9affc/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f4f70656e4275696c64696e67732f656e7669726f6e6d656e742d6261636b75702f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/OpenBuildings/environment-backup?branch=master)
==============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#environment-backup--)

Set environment variables: globals, static vars, kohana configs etc. and later restore their original values. This is useful testing when you want to have a specific environment set for the test, but don't want that test to affect other code outside of it.

The environment class is initialized with some environment groups, each handling specific type of environment. You can easily add more classes to handle different environments.

Each environment group that you add allows has a unique name of "naming" its variables so that it knows how to handle their backup

- '\_POST', '\_GET', '\_FILES', '\_SERVER', '\_COOKIE' and '\_SESSION' are handled by the 'Environment\_Group\_Globals',
- 'REMOTE\_HOST', 'CLIENT\_IP' and all the other variables inside the '\_SERVER' variable are handled by Environment\_Group\_Server (this is used to easily backup restore only sertain variables of the $\_SERVER super global)
- 'SomeClass::$variable' is used to handle stativ variables - it can backup / restore public, protected and private ones by Environment\_Group\_Static
- 'group.config\_var' is used to handle Kohana config settings by Environment\_Group\_Config - this is used only in a Kohana Framwork environment

Example:

```
$environment = new Environment(array(
	'globals' => new Environment_Group_Globals(),
	'server' => new Environment_Group_Server(),
	'static' => new Environment_Group_Static(),
));

$environment->backup_and_set(array(
	'_POST' => array('new stuff'),
	'REMOTE_HOST' => 'example.com',
	'MyClass::$private_var' => 10
));

// Do some stuff that changes / uses these variables

$environment->restore();
```

License
-------

[](#license)

Copyright (c) 2012-2013, OpenBuildings Ltd. Developed by Ivan Kerin as part of [clippings.com](http://clippings.com)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community22

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

Total

3

Last Release

3516d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/506129?v=4)[Harry Dobrev](/maintainers/hkdobrev)[@hkdobrev](https://github.com/hkdobrev)

![](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)

![](https://avatars.githubusercontent.com/u/745771?v=4)[Filip Georgiev](/maintainers/phgeorgiev)[@phgeorgiev](https://github.com/phgeorgiev)

![](https://avatars.githubusercontent.com/u/490439?v=4)[Zdravko Evstatiev](/maintainers/zedevs)[@zedevs](https://github.com/zedevs)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/openbuildings-environment-backup/health.svg)

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

PHPackages © 2026

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