PHPackages                             mnshankar/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. [File &amp; Storage](/categories/file-storage)
4. /
5. mnshankar/csv

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

mnshankar/csv
=============

Easily generate CSV files

1.8(10y ago)45338.8k↓40.4%10[2 issues](https://github.com/mnshankar/csv/issues)[1 PRs](https://github.com/mnshankar/csv/pulls)MITPHPPHP &gt;=5.3.0

Since Dec 1Pushed 9y ago3 watchersCompare

[ Source](https://github.com/mnshankar/csv)[ Packagist](https://packagist.org/packages/mnshankar/csv)[ RSS](/packages/mnshankar-csv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (10)Used By (0)

[![Build Status](https://camo.githubusercontent.com/ea1e8d7f971b4a29c33f88275b0d6c07207c3066e9179f4b903e69fdfba4284e/68747470733a2f2f7472617669732d63692e6f72672f6d6e7368616e6b61722f6373762e706e67)](https://travis-ci.org/mnshankar/csv)

Easy CSV file manipulation (Read, Write and Download)
-----------------------------------------------------

[](#easy-csv-file-manipulation-read-write-and-download)

This is a simple utility package that helps you work with CSV files.

\##Installation with Composer

Add this line to your composer.json file in the `require field:

```
"mnshankar/CSV": "1.8"
```

\##Generic PHP Project or Laravel 5+ Project

Since this package does not have any framework specific dependencies (or any dependencies for that matter), directly instantiate a CSV object in your code like so

```
$csvObj = new mnshankar\CSV\CSV();

```

Then, use regular PHP object calls like so:

```
$arr = array(
    array('col1'=>'a','col2'=>'b'),
    array('col1'=>'1','col2'=>'2'),
    array('col1'=>'3','col2'=>'4'),
);
return $csvObj->fromArray($arr)->render('myfile.csv');                  //download as csv;
return $csvObj->fromArray($arr)->withSeparator()->render('myfile.csv'); //add delimiter for better excel compatibility & download
return $csvObj->with($arr)->put('/downloads/myusers.csv');	            //store as csv in this path
return $csvObj->fromFile('/downloads/my.csv')->toArray();               //return csv file as an array
return $csvObj->fromFile('/downloads/my.csv')->render('abc.csv');       //render saved csv file as a downloadable document
return $csvObj->with('/downloads/my.csv')->render('abc.csv');           //use 'with'.. same as previous

```

\##Laravel 4 CSV has (optional) support for Laravel, and comes with a Service Provider and Facades for easy integration. Open `app/config/app.php` and add the following line in the `providers` array:

```
'providers' => array(
    'mnshankar\CSV\CSVServiceProvider',
)
```

and the following in the 'alias' array

```
'alias' => array(
    'CSV'             =>'mnshankar\CSV\CSVFacade',
)
```

Now, in your application you can work with CSV files like so:

```
$arr = User::all()->toArray();	//use eloquent to get array of all users in 'users' table

return CSV::with($arr)->put(storage_path().'/downloads/myusers.csv');	//store as csv in this path
return CSV::fromArray($arr)->render();	//download as csv
return CSV::fromFile(storage_path().'/downloads/my.csv')->toArray();    //return csv file as an array
return CSV::fromFile(storage_path().'/downloads/my.csv')->render('abc.csv'); //render saved csv file as a downloadable document
return CSV::with(storage_path().'/downloads/my.csv')->render('abc.csv'); //use 'with'.. same as previous
```

Note that the 'with' statement can accept either an array or file path, and work accordingly.

### License

[](#license)

This is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 68.8% 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 ~77 days

Recently: every ~43 days

Total

9

Last Release

3927d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec7d6db9c6a284d9ca1fb934910bb11c1eb3aaab1d9fc9daa5e92f98a43a37d6?d=identicon)[mnshankar](/maintainers/mnshankar)

---

Top Contributors

[![mnshankar](https://avatars.githubusercontent.com/u/2873887?v=4)](https://github.com/mnshankar "mnshankar (11 commits)")[![4lb0](https://avatars.githubusercontent.com/u/142173?v=4)](https://github.com/4lb0 "4lb0 (2 commits)")[![adrianthedev](https://avatars.githubusercontent.com/u/1334409?v=4)](https://github.com/adrianthedev "adrianthedev (2 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

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

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15161.6M2.6k](/packages/illuminate-filesystem)[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)[madnest/madzipper

Easier zip file handling for Laravel applications.

1382.3M6](/packages/madnest-madzipper)

PHPackages © 2026

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