Hugo Sales e8e8000b16 Update composer dependencies | 4 yıl önce | |
---|---|---|
.. | ||
src | 4 yıl önce | |
CHANGELOG.md | 4 yıl önce | |
LICENSE.md | 4 yıl önce | |
README.md | 4 yıl önce | |
composer.json | 4 yıl önce | |
composer.lock | 4 yıl önce | |
psalm.xml | 4 yıl önce |
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 Webimpress\SafeWriter\Exception\ExceptionInterface
)
will be thrown.