Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mortalflesh/csv-exporter
Csv exporter for Symfony
https://github.com/mortalflesh/csv-exporter
csv csv-export symfony
Last synced: 11 days ago
JSON representation
Csv exporter for Symfony
- Host: GitHub
- URL: https://github.com/mortalflesh/csv-exporter
- Owner: MortalFlesh
- License: mit
- Created: 2017-10-09T21:12:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-21T16:06:01.000Z (about 2 years ago)
- Last Synced: 2024-10-20T23:15:06.571Z (27 days ago)
- Topics: csv, csv-export, symfony
- Language: PHP
- Homepage:
- Size: 34.2 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
CSV Exporter
============[![Latest Stable Version](https://img.shields.io/packagist/v/mf/csv-exporter.svg)](https://packagist.org/packages/mf/csv-exporter)
[![Total Downloads](https://img.shields.io/packagist/dt/mf/csv-exporter.svg)](https://packagist.org/packages/mf/csv-exporter)
[![License](https://img.shields.io/packagist/l/mf/csv-exporter.svg)](https://packagist.org/packages/mf/csv-exporter)
[![Tests and linting](https://github.com/MortalFlesh/csv-exporter/actions/workflows/tests.yaml/badge.svg)](https://github.com/MortalFlesh/csv-exporter/actions/workflows/tests.yaml)
[![Coverage Status](https://coveralls.io/repos/github/MortalFlesh/csv-exporter/badge.svg?branch=master)](https://coveralls.io/github/MortalFlesh/csv-exporter?branch=master)Csv exporter for [Symfony](https://github.com/symfony/symfony)
## Installation
```bash
$ composer require mf/csv-exporter
```## Requirements
- `PHP 8.0`
- [league/csv](https://github.com/thephpleague/csv)## Usage
> For detail explanation see [this issue](https://github.com/MortalFlesh/csv-exporter/issues/2#issuecomment-782130283)
### In Symfony Controller action
```php
return (new StreamedResponseFactory(/* ...dependencies */)) // from ->get('service')
->createCsv(
'filename.csv',
[
'columns...',
],
function ($offset, $bulk) use ($repository) {
return $repository->findBulkForExport($offset, $bulk);
},
function (array $row) {
return [
$row['key'],
];
}
);
```