webimpress / safe-writer
安全写入文件的工具,以避免竞态条件
2.2.0
2021-04-19 16:34 UTC
Requires
- php: ^7.3 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.5.4
- vimeo/psalm: ^4.7
- webimpress/coding-standard: ^1.2.2
This package is auto-updated.
Last update: 2024-09-19 14:10:35 UTC
README
安全写入文件,以避免在短时间内多次写入同一文件时发生竞态条件。
安装
使用 composer
composer require webimpress/safe-writer
使用方法
use Webimpress\SafeWriter\FileWriter; $targetFile = __DIR__ . '/target-file.php'; $content = "<?php\nreturn " . var_export($data, true) . ';'; FileWriter::writeFile($targetFile, $content);
如果出现问题,将抛出异常(Webimpress\SafeWriter\Exception\ExceptionInterface
实例)。