Need help with safe-writer?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

363 Stars 7 Forks BSD 2-Clause "Simplified" License 105 Commits 3 Opened issues


Write files safely, to avoid race conditions

Services available


Need anything else?

Contributors list

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.


Using 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);

If something goes wrong exception (instance of

) will be thrown.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.