# sebastianbergmann/global-state

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/sebastianbergmann-global-state).**

6,606 stars · 19 forks · PHP · BSD-3-Clause

## Links

- GitHub: https://github.com/sebastianbergmann/global-state
- awesome-repositories: https://awesome-repositories.com/repository/sebastianbergmann-global-state.md

## Description

This project is a PHP environment manager and testing utility designed to back up and revert the global application state. It functions as a snapshotter that captures the current state of global variables and settings to prevent side effects between different execution contexts.

The tool focuses on automating testing environment control and ensuring test isolation within PHPUnit suites. It accomplishes this by snapshotting and reverting global state changes during execution to create predictable and reproducible conditions for software tests.

The system implements a backup-and-restore cycle that monitors changes to superglobals and server settings. This allows the environment to be returned to a known previous configuration through a restore-point mechanism.

## Tags

### Testing & Quality Assurance

- [Test Isolation](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-isolation.md) — Ensures PHPUnit tests start with a clean environment by reverting global state changes.
- [Environment State Backups](https://awesome-repositories.com/f/testing-quality-assurance/environment-state-backups.md) — Provides a backup-and-restore cycle to capture and revert the PHP environment state between test executions.
- [Testing Utilities](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/end-to-end-testing-suites/end-to-end-testing-frameworks/testing-utilities.md) — Provides a specialized component for managing environment snapshots during the execution of automated PHP test suites.

### Part of an Awesome List

- [State Snapshotters](https://awesome-repositories.com/f/awesome-lists/devtools/global-variables-and-environments/state-snapshotters.md) — Captures and restores the state of PHP global variables and settings to isolate test environments.

### Data & Databases

- [State Capturing](https://awesome-repositories.com/f/data-databases/application-state-management/global-application-state/state-capturing.md) — Snapshots current global variables and settings to a backup to return the environment to its previous state. ([source](https://github.com/sebastianbergmann/global-state/tree/main/.phive))
- [Environment State Restoration](https://awesome-repositories.com/f/data-databases/data-restoration-tools/environment-state-restoration.md) — Implements a restore-point mechanism to revert global environment variables to a previously saved state.
- [State Snapshots](https://awesome-repositories.com/f/data-databases/data-snapshotting/state-snapshots.md) — Captures the current values of global variables and constants as snapshots for later restoration.
- [PHP Runtime Snapshotting](https://awesome-repositories.com/f/data-databases/data-snapshotting/state-snapshots/php-runtime-snapshotting.md) — Captures the state of global PHP data to restore the system to a known previous configuration.

### Development Tools & Productivity

- [Environment State Managers](https://awesome-repositories.com/f/development-tools-productivity/environment-state-managers.md) — Functions as a mechanism for backing up and reverting global application state to prevent side effects.

### Programming Languages & Runtimes

- [Global State Management](https://awesome-repositories.com/f/programming-languages-runtimes/global-state-management.md) — Saves and restores global variables and environment settings to prevent side effects between program components.
- [Runtime Variable Tracking](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-variable-tracking.md) — Monitors changes to PHP superglobals and server settings to maintain a consistent system environment.

### Software Engineering & Architecture

- [Controlled Environment Test Executions](https://awesome-repositories.com/f/software-engineering-architecture/sandboxed-execution-environments/test-environment-isolation/controlled-environment-test-executions.md) — Manages the state of global variables to create predictable and reproducible conditions for automated tests.
