PHPackages                             yohns/filewriter - 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. yohns/filewriter

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

yohns/filewriter
================

File writing utility for PHP

0.1.1(1y ago)04MITPHPPHP ^7.4|^8.0

Since Nov 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Yohn/FileWriter)[ Packagist](https://packagist.org/packages/yohns/filewriter)[ RSS](/packages/yohns-filewriter/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

FileWriter PHP Utility
======================

[](#filewriter-php-utility)

Overview
--------

[](#overview)

The `FileWriter` class provides a simple and robust utility for writing content to files with various operations like overwriting, appending, and prepending.

Installation
------------

[](#installation)

Install via Composer:

```
composer require yohns/filewriter
```

Requirements
------------

[](#requirements)

- PHP 7.4+
- Ext-fileinfo recommended

Usage Examples
--------------

[](#usage-examples)

### Basic File Writing

[](#basic-file-writing)

```
use Yohns\Util\FileWriter;

// Create a new FileWriter instance
$fileWriter = new FileWriter('path/to/your/file.txt');

// Overwrite file content
$fileWriter->overwrite("Hello, world!\n");

// Append to file
$fileWriter->append("Additional content\n");

// Prepend to file
$fileWriter->prepend("Initial content\n");
```

### Handling File Operations

[](#handling-file-operations)

```
$fileWriter = new FileWriter('logs/app.log');

// Safely write content, with error handling
if (!$fileWriter->append("Log entry: " . date('Y-m-d H:i:s') . "\n")) {
    // Handle writing error
    error_log("Could not write to log file");
}
```

Features
--------

[](#features)

- Automatic directory creation
- File creation if not exists
- Overwrite, append, and prepend operations
- File locking to prevent race conditions

Error Handling
--------------

[](#error-handling)

Methods return boolean values:

- `true`: Operation successful
- `false`: Operation failed

License
-------

[](#license)

MIT License

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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 ~0 days

Total

2

Last Release

588d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2002591?v=4)[JWB](/maintainers/Yohn)[@Yohn](https://github.com/Yohn)

---

Top Contributors

[![Yohn](https://avatars.githubusercontent.com/u/2002591?v=4)](https://github.com/Yohn "Yohn (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yohns-filewriter/health.svg)

```
[![Health](https://phpackages.com/badges/yohns-filewriter/health.svg)](https://phpackages.com/packages/yohns-filewriter)
```

PHPackages © 2026

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