2017 © Pedro Peláez
 

library environment-backup

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

image

openbuildings/environment-backup

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

  • Wednesday, August 2, 2017
  • by hkdobrev
  • Repository
  • 10 Watchers
  • 1 Stars
  • 41,222 Installations
  • PHP
  • 8 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 11 % Grown

The README.md

Environment Backup Build Status Coverage Status

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., (*1)

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., (*2)

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

  • '_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:, (*4)

$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

Copyright (c) 2012-2013, OpenBuildings Ltd. Developed by Ivan Kerin as part of clippings.com, (*5)

Under BSD-3-Clause license, read LICENSE file., (*6)

The Versions

02/08 2017

dev-master

9999999-dev

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

  Sources   Download

BSD-3-Clause

The Development Requires

01/10 2016

0.1.2

0.1.2.0

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

  Sources   Download

BSD-3-Clause

The Development Requires

24/07 2013

0.1.1

0.1.1.0

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

  Sources   Download

BSD-3-Clause

The Development Requires

23/07 2013

0.1.0

0.1.0.0

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

  Sources   Download

BSD-3-Clause

The Development Requires