PHPackages                             folded/file - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. folded/file

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

folded/file
===========

Manipulate files with functions for your web app.

v0.2.0(5y ago)0221MITPHP

Since Oct 10Pushed 5y ago2 watchersCompare

[ Source](https://github.com/folded-php/file)[ Packagist](https://packagist.org/packages/folded/file)[ RSS](/packages/folded-file/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (5)Versions (3)Used By (1)

folded/history
==============

[](#foldedhistory)

Manipulate files with functions for your web app.

[![Build Status](https://camo.githubusercontent.com/ed20facf9b0cee005fbb4d205dd3aef3aec72aac328a536b64720c974c9e8748/68747470733a2f2f7472617669732d63692e636f6d2f666f6c6465642d7068702f66696c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/folded-php/file) [![Maintainability](https://camo.githubusercontent.com/35c6b35eef391a60b4d93ff6e425805f8e901a78f05a717537d3721ca03aff82/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f62356135616633663930613561343239666563332f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/folded-php/file/maintainability) [![TODOs](https://camo.githubusercontent.com/30ece6c6f79b14403944321fb0cec1f28336ac556c324fd87c14aad3e463a817/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6170692e7469636b6769742e636f6d2f62616467653f7265706f3d6769746875622e636f6d2f666f6c6465642d7068702f66696c65)](https://www.tickgit.com/browse?repo=github.com/folded-php/file)

Summary
-------

[](#summary)

- [About](#about)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [Version support](#version-support)

About
-----

[](#about)

I created this library, to avoid having to throw exception in my code when I use the file functions.

Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.

- [folded/action](https://github.com/folded-php/action): A way to organize your controllers for your web app.
- [folded/config](https://github.com/folded-php/config): Configuration utilities for your PHP web app.
- [folded/crypt](https://github.com/folded-php/crypt): Encrypt and decrypt strings for your web app.
- [folded/exception](https://github.com/folded-php/exception): Various kind of exception to throw for your web app.
- [folded/history](https://github.com/folded-php/history): Manipulate the browser history for your web app.
- [folded/http](https://github.com/folded-php/http): HTTP utilities for your web app.
- [folded/orm](https://github.com/folded-php/orm): An ORM for you web app.
- [folded/routing](https://github.com/folded-php/routing): Routing functions for your PHP web app.
- [folded/request](https://github.com/folded-php/request): Request utilities, including a request validator, for your PHP web app.
- [folded/session](https://github.com/folded-php/session): Session functions for your web app.
- [folded/view](https://github.com/folded-php/view): View utilities for your PHP web app.

Features
--------

[](#features)

- Will throw an Exception if an error occured while using the functions
- Have the exact same signature as the native functions

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

[](#requirements)

- PHP version &gt;= 7.4.0
- Composer installed

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

[](#installation)

In your root folder, run this command:

```
composer required folded/file
```

Examples
--------

[](#examples)

- [1. Open a file](#1-open-a-file)
- [2. Close a file](#2-close-a-file)
- [3. Delete a file](#3-delete-a-file)
- [4. Write a CSV row to a file](#4-write-a-csv-row-to-a-file)
- [5. Read a CSV row from a file](#5-read-a-csv-row-from-a-file)
- [6. Rename a file](#6-rename-a-file)
- [7. Write on file](#7-write-on-file)

### 1. Open a file

[](#1-open-a-file)

In this example, we will get an opened file.

```
use function Folded\openFile;

$file = openFile("path/to/file.txt", "r");
```

### 2. Close a file

[](#2-close-a-file)

In this example, we will close an opened file.

```
use function Folded\openFile;
use function Folded\closeFile;

$file = openFile("path/to/file.txt", "r");

closeFile($file);
```

### 3. Delete a file

[](#3-delete-a-file)

In this example, we will delete an existing file.

```
use function Folded\deleteFile;

deleteFile("path/to/file.txt");
```

### 4. Write a CSV row to a file

[](#4-write-a-csv-row-to-a-file)

In this example, we will write a CSV row in a file.

```
use function Folded\openFile;
use function Folded\addCsvRowToFile;

$file = openFile("path/to/file.csv", "w");

addCsvRowToFile($file, ["foo", "bar"]);
```

### 5. Read a CSV row from a file

[](#5-read-a-csv-row-from-a-file)

In this example, we will get a CSV row from a file. Subsequent calls will get the next rows from the file.

```
use function Folded\openFile;
use function Folded\getCsvRowFromFile;

$file = openFile("path/to/file.csv", "r");

$firstRow = getCsvRowFromFile($file);
$secondRow = getCsvRowFromFile($file);
```

### 6. Rename a file

[](#6-rename-a-file)

In this example, we will rename a file.

```
use function Folded\changeName;

changeName("path/to/old.txt", "path/to/new.txt");
```

### 7. Write on file

[](#7-write-on-file)

In this example, we will write on an opened file.

```
use function Folded\writeOnFile;

$file = fopen("path/to/file.txt");

writeToFile($file, "some text");
```

If you need to get the number of bytes written, get the return of the function.

```
use function Folded\writeOnFile;

$file = fopen("path/to/file.txt");

$numberOfBytesWritten = writeToFile($file, "some text");

echo "$numberOfBytesWritten bytes written";
```

Version support
---------------

[](#version-support)

7.37.48.0v0.1.0❌✔️❓v0.2.0❌✔️❓

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

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

Total

2

Last Release

2045d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15908747?v=4)[Anwar](/maintainers/khalyomede)[@khalyomede](https://github.com/khalyomede)

---

Top Contributors

[![khalyomede](https://avatars.githubusercontent.com/u/15908747?v=4)](https://github.com/khalyomede "khalyomede (13 commits)")

---

Tags

csvfilephp

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/folded-file/health.svg)

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

###  Alternatives

[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.2k57.6M131](/packages/openspout-openspout)[veewee/xml

XML without worries

1835.9M29](/packages/veewee-xml)[setasign/tfpdf

This class is a modified version of FPDF that adds UTF-8 support. The latest version is based on FPDF 1.85.

426.1M30](/packages/setasign-tfpdf)[aspera/xlsx-reader

Spreadsheet reader library for XLSX files

52742.2k5](/packages/aspera-xlsx-reader)

PHPackages © 2026

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