PHPackages                             crodas/concurrent-file-writer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. crodas/concurrent-file-writer

ActiveLibrary[File &amp; Storage](/categories/file-storage)

crodas/concurrent-file-writer
=============================

Tiny library to write files concurrently with PHP

v0.2.2(8y ago)08511MITPHP

Since Jul 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/crodas/ConcurrentFileWriter)[ Packagist](https://packagist.org/packages/crodas/concurrent-file-writer)[ RSS](/packages/crodas-concurrent-file-writer/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (6)Used By (1)

Concurrent File Writer
======================

[](#concurrent-file-writer)

Writing files in PHP, specially if multiple process may be writing it at the time is hard. File locking is hard to do it right and it is inneficient.

This is a tiny library to write files in parallel using as less file locking as possible. This library was designed to improve [crodas/EzUpload](https://github.com/crodas/EzUpload)

How to install?
---------------

[](#how-to-install)

It can be installed with composer with the following command:

```
composer require crodas/concurrent-file-writer
```

How does it work?
-----------------

[](#how-does-it-work)

When a file is created, a placeholder file is created with some metadata. Each `write` call creates a new chunk, which is stored in a temporary folder. When all the chunks has been writen, the `finalize` function will lock the file and will merge all the chunks into the final, and cleanup all the temporary files.

Usage
-----

[](#usage)

```
use ConcurrentFileWriter\ConcurrentFileWriter;

$x = new ConcurrentFileWriter('/tmp/file.txt');

// This will return TRUE the first time, FALSE if the file is already create and in process and an exception is the file exists and it seems to be finished.
$x->create();

// This calls can happen in parallel (with the same initialization as above).
$x->write( $offset, $content );
$x->write( $offset, $content );

// Only one process can finalize the file writing, it will block.
// Finalize will return TRUE on success FALSE if another process is already doing it.
$x->finalize();
```

TODO
----

[](#todo)

- More PHPDocs
- More PHPUnit to cover all corner cases
- More PHPUnit with real parallelism (spawning a real webserver or multiple PHP process?)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

4

Last Release

3213d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36463?v=4)[C](/maintainers/crodas)[@crodas](https://github.com/crodas)

---

Top Contributors

[![crodas](https://avatars.githubusercontent.com/u/36463?v=4)](https://github.com/crodas "crodas (27 commits)")

### Embed Badge

![Health badge](/badges/crodas-concurrent-file-writer/health.svg)

```
[![Health](https://phpackages.com/badges/crodas-concurrent-file-writer/health.svg)](https://phpackages.com/packages/crodas-concurrent-file-writer)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
