tao-test/app/vendor/webimpress/safe-writer
2022-08-29 20:14:13 +02:00
..
src Code, before instalation. 2022-08-29 20:14:13 +02:00
CHANGELOG.md Code, before instalation. 2022-08-29 20:14:13 +02:00
composer.json Code, before instalation. 2022-08-29 20:14:13 +02:00
composer.lock Code, before instalation. 2022-08-29 20:14:13 +02:00
LICENSE.md Code, before instalation. 2022-08-29 20:14:13 +02:00
psalm.xml Code, before instalation. 2022-08-29 20:14:13 +02:00
README.md Code, before instalation. 2022-08-29 20:14:13 +02:00

Webimpress Safe Writer

Unit Tests Coding Standards Static Analysis Coverage Status

Write files safely to avoid race conditions when the same file is written multiple times in a short time period.

Installation

Using composer:

$ composer require webimpress/safe-writer

Usage

use Webimpress\SafeWriter\FileWriter;

$targetFile = __DIR__ . '/target-file.php';
$content = "<?php\nreturn " . var_export($data, true) . ';';

FileWriter::writeFile($targetFile, $content);

If something goes wrong exception (instance of Webimpress\SafeWriter\Exception\ExceptionInterface) will be thrown.