PHPackages                             yazanstash/csv - 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. yazanstash/csv

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

yazanstash/csv
==============

A nice API to write csv files.

v0.2.0(3y ago)06.2kMITPHPPHP ^7.0|^8.0CI failing

Since Oct 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Yazan-Stash/csv)[ Packagist](https://packagist.org/packages/yazanstash/csv)[ Docs](https://github.com/yazan-stash/csv)[ RSS](/packages/yazanstash-csv/feed)WikiDiscussions master Synced 2d ago

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

A nice API to write CSV files.
==============================

[](#a-nice-api-to-write-csv-files)

This is just a very light weight package to write to a csv file, it's basically a wrapper around `fputcsv`. It also handles the file's creation, opening and closing.

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

[](#installation)

You can install the package via composer:

```
composer require yazanstash/csv
```

Usage
-----

[](#usage)

```
$file = YazanStash\Csv::create();
// or
$file = YazanStash\Csv::create('/home/stash/Desktop/export.csv');

$file->delimiter('|')->enclosure("'")->write(['Hola Amigo!']);
```

You can choose between providing a file path and name to the `create()` method or letting it generate one, by default the generated file is located at `/tmp/{random-file-name}.csv`.
**Caution:** If the file already exists, the package will overwrite it.

#### Customizing the write parameters

[](#customizing-the-write-parameters)

To customize the parameters of writing, you have 3 dynamic methods available at your disposal, `delimiter()`, `enclosure()` and `escapeCharacter()`. Passing an argument will change the value, and calling the method without it will give you the current value of it. In the case of overwriting the value, it will give you back the object for those sick chains ;)

#### Writing to file

[](#writing-to-file)

Use the `write()` method to write new lines to the file, the method expects an array of values to be written.
each call to `write()` will create a new line.

#### Getting the file path back

[](#getting-the-file-path-back)

To get the written file path back, just call `filePath()` on the instance.

#### Manually closing the file

[](#manually-closing-the-file)

If you need to close the file manually for some reason (the package automatically does that upon destructing the instance), you can call `closeFile()` on the instance.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Yazan Stash](https://github.com/Yazan-Stash)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Total

2

Last Release

1368d ago

PHP version history (2 changes)v0.1.0PHP ^7.0

v0.2.0PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f2b75baf734b1475617e133c55f0f3541af08d36e0759fb560dce46aeaeab1c8?d=identicon)[Yazan-Stash](/maintainers/Yazan-Stash)

---

Top Contributors

[![Yazan-Stash](https://avatars.githubusercontent.com/u/28860695?v=4)](https://github.com/Yazan-Stash "Yazan-Stash (1 commits)")

---

Tags

csvstashyazan

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yazanstash-csv/health.svg)

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

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k152.8M851](/packages/maatwebsite-excel)[league/csv

CSV data manipulation made easy in PHP

3.5k176.5M798](/packages/league-csv)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k26.3M51](/packages/rap2hpoutre-fast-excel)[openspout/openspout

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

1.2k65.5M210](/packages/openspout-openspout)[goodby/csv

CSV import/export library

9535.6M25](/packages/goodby-csv)[sonata-project/exporter

Lightweight Exporter library

44121.3M38](/packages/sonata-project-exporter)

PHPackages © 2026

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