2017 © Pedro Peláez
 

library streamed-csv-response

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

image

issei-m/streamed-csv-response

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  • Tuesday, March 6, 2018
  • by issei-m
  • Repository
  • 2 Watchers
  • 4 Stars
  • 8,676 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 10 Versions
  • 6 % Grown

The README.md

StreamedCsvResponse

SensioLabsInsight, (*1)

Build Status Scrutinizer Code Quality Code Coverage License, (*2)

Extending the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client. It works with Symfony 2.7 and newer (including 3 and 4 of course) on PHP 7.x., (*3)

Usage

Very easy, just pass two arguments to the constructor. For instance in Symfony's controller:, (*4)

public function exportCustomersAction(Request $request)
{
    return new StreamedCsvResponse(
        // 1st parameter: any iterable CSV rows
        (function () {
            yield ['Full Name', 'Email', 'Gender'];

            foreach ($this->get('user_repository')->getAllUsers() as $user) {
                yield [
                    $user->getFullName(),
                    $user->getEmail(),
                    $user->getGender(),
                ];
            }

            // Of course, you can also use any iterable for cell representation
            yield (function () {
                yield '村澤 逸生';
                yield 'issei.m7@gmail.com';
                yield '男性';
            })();
        })(),

        // 2nd parameter: the filename the browser uses in downloading 
        'customers.csv'
    ); 
}

auto encoding

If the response has been set any charset, every cell content will be encoded accordingly when sending:, (*5)

$response = new StreamedCsvResponse($rows, 'customers.csv');
$response->setCharset('SJIS-win');

$response->send(); // Every cells are automatically encoded to SJIS-win.

Installation

Use Composer to install the package:, (*6)

$ composer require issei-m/streamed-csv-response

The Versions

06/03 2018

dev-master

9999999-dev

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

06/03 2018

dev-revert-bump-up-version-to-12

dev-revert-bump-up-version-to-12

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

05/03 2018

dev-start-php53-support-again

dev-start-php53-support-again

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

03/03 2018

dev-add-git-attribtues

dev-add-git-attribtues

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

03/03 2018

dev-support-sf4

dev-support-sf4

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

17/05 2017

dev-avoid-unnecesarry-enclosing

dev-avoid-unnecesarry-enclosing

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

16/05 2017

v1.1

1.1.0.0

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

14/05 2017

v1.0.2

1.0.2.0

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony export response download

14/04 2016

v1.0.1

1.0.1.0

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony response

22/01 2015

v1.0

1.0.0.0

Extends the Symfony\Component\HttpFoundation\StreamedResponse to send a CSV file to client.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Issei Murasawa

csv symfony response