hashemi/php-csv-export

A simple & lightweight csv export package for php

dev-master 2024-03-14 07:55 UTC

This package is auto-updated.

Last update: 2024-11-14 09:34:49 UTC


README

A simple & lightweight csv export package for PHP

Installation

You can start it from composer. Go to your terminal and run this command from your project root directory.

composer require hashemi/php-csv-export

Usage

After Complete installation, It's time to check how to use.

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Hashemi\CsvExport\CsvExport;

$headers = [
    'id',
    'name',
    'age'
];

$rows = [
    [1, 'Foo', 12],
    [2, 'Bar', 34],
    [3, 'John', 12]
];

(new CsvExport())
    ->setHeaders($headers)
    ->setRows($rows)
    ->setFileName('employee.csv')
    ->download();

// or

(new CsvExport($headers, $rows, 'employee.csv'))->download();

Contributing

Pull requests are welcome. For any changes, please open an issue first to discuss what you would like to change.