ferdous / flock-write
This is a library for File lock write operation in a single shared storage
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ferdous/flock-write
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^6.0
This package is auto-updated.
Last update: 2025-09-28 01:49:30 UTC
README
This library is for simultaneous write on a single file with locking mechanism by PHP flock function. It uses the unix semaphore to lock the file and hence a safe application to store data in a single file shared by multiple methods.
Installation
This library is compatible with all PHP version starting from 4 to 8. Just run the following command to install.
composer require ferdous/flock-write
How to add
Add the following operations to the namespace
use Ferdous\FileLockWrite\FileOperation; use Ferdous\FileLockWrite\LockService;
Now you are ready to add the functionality by creating the object
$lockService = new LockService(); $opObj = new FileOperation($filepath, $filename, $lockService, $data);
Operations
- Truncate File
$opObj->truncateFile()
- Write File with Exclude Lock
$opObj->writeDataToFileAppend()
- Read File with Shared Lock
$opObj->readDataFromFile()
Unit Tests
For checking the unit tests run
./vendor/bin/phpunit . --testdox --color