nette/safe-stream
Nette SafeStream provides a stream wrapper for atomic file operations, ensuring files are never left partially written or corrupted. It supports file locking and safe concurrent access, making it ideal for writing configs, caches, and logs reliably in PHP applications.
NOASSERTION — legal must confirm terms before it ships in a commercial product; (2) provenance is unverified (repository unknown in this data), so pin a version and review the source before merge.Adopt when most of these are true:
rename() over an existing file is atomic.file_put_contents('safe://…') and friends keep working.Look elsewhere when:
fsync-backed durability of contents. Wrong tool.For executives (one paragraph): We have a recurring class of bug where a file is read while it's still being written, or a process dies mid-write, and the user sees a corrupted or empty file. This package makes those writes atomic with a one-line change at the call site and no new infrastructure cost. It's a small, mature, single-purpose open-source utility — low integration cost, low operational overhead, and it removes a support-ticket category rather than adding a system to run. Two things need sign-off before we ship it: a legal check on the license, and a source review of the pinned version.
For engineering: It's a PHP stream wrapper (safe://) that routes native fopen/file_get_contents/file_put_contents/unlink calls through atomic write semantics — write to a temp file, then rename into place, so readers never observe a partial file and a crash can't leave a truncated artifact. It is deliberately narrow: no locking, no fsync guarantees, no abstraction over disks. Treat it as a drop-in at specific call sites, not a global filesystem layer. Note it does not integrate automatically with Laravel's Storage/Flysystem facade — using it means calling native functions against a safe:// path (or wrapping it in a custom adapter), so scope the integration explicitly rather than assuming Storage::put gets safer for free.
Knowns and unknowns to state up front: license unresolved (NOASSERTION), provenance unverified in this dataset, low star count / single maintainer, and filesystem-behavior dependencies (Linux local disk yes; NFS/Windows need testing). All are manageable for a small, pinned, well-reviewed dependency — but they should be decisions we make, not assumptions we inherit.
How can I help you explore Laravel packages today?