• Stars
    star
    376
  • Rank 113,464 (Top 3 %)
  • Language
    PHP
  • License
    BSD 2-Clause "Sim...
  • Created almost 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Write files safely, to avoid race conditions

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.