vlw/globalsnapshot
最新稳定版本:1.0.3
Composer 安装命令:
composer require vlw/globalsnapshot
包简介
Capture and restore the state of all PHP superglobals.
README 文档
README
Capture the current state of all PHP superglobal variables - which can then be restored to the state of capture at a later time.
Supports PHP 8.1+
Example use:
// Initial state
$_ENV["hello"] = "world"; // echo: "world"
// Capture initial state
$snapshot = (new GlobalSnapshot())->capture();
// Manipulate superglobals
$_ENV["hello"] .= " and mom!"; // echo: "world and mom"
// Restore initial state
$snapshot->restore();
// Initial state restored
echo $_ENV["hello"]; // echo: "world"
Quickstart
Install with composer
composer install vlw/globalsnapshotusein your projectuse vlw\GlobalSnapshot;Capture current superglobals with
capture()// Initialize a new GlobalSnapshot instance to store current values (one snapshot per instance) $snapshot = new GlobalSnapshot();
// Capture current superglobal state $snapshot->capture();
3. Restore superglobals with `restore()`
// ... some other code
// Restore superglobals to state of capture()
$snapshot->restore();
统计信息
- 总下载量: 48
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unlicense
- 更新时间: 2024-11-23