PHPackages                             netsells/csvme - 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. netsells/csvme

AbandonedArchivedLibrary

netsells/csvme
==============

An opinionated library to make exporting data in CSV format super simple.

1.1.0(7y ago)45.4k↓50%11MITPHP

Since Aug 6Pushed 4y agoCompare

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

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

Csvme
=====

[](#csvme)

[![Latest Version](https://camo.githubusercontent.com/273dc43287f81f7bb4d3a6556ae206204ed401ed0580c7dec7be0a6790225af4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6e657473656c6c732f6373766d652e7376673f7374796c653d666c61742d737175617265)](https://github.com/netsells/csvme/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/5c71f5b95fc068d9f2222d6a1b6d47ca887f87d1f6f5f84e5c60693ff859e42d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e657473656c6c732f6373766d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/netsells/csvme)

Csvme is an opinionated library that utilises the `league/csv` library.

It is created and maintained by the [Netsells team](https://netsells.co.uk/)

Install
-------

[](#install)

Install `Csvme` using Composer.

```
$ composer require netsells/csvme

```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Csvme always expects an array of objects and optionally a layout closure for the header row.

```
$csv = new Csvme();

$csv->withHeader(['ID', 'Total', 'Number of Items', 'Created At'])
    ->withLayout(function(Order $order) {
        return [
            $order->id,
            $order->total,
            $order->items->count(),
            $order->created_at->format('d-m-Y'),
        ];
    })
    ->withItems($orders)
    ->output();
```

### CSV Composers

[](#csv-composers)

It is possible to use an external class to offload the layout of the CSV to a dedicated file.

```
$csv = new Csvme();
$csv->output(new OrderExportComposer($orders));
```

```
