silverkron / php-csv-builder
Build csv file and save or download it
v1.0.1
2018-02-23 15:31 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2025-07-06 08:59:57 UTC
README
Build csv file and save or download it. Simple librery to write csv file in your php application
Install
Install php-csv-builder
with Composer.
$ composer require silverkron/php-csv-builder
Initialize the class
use CsvBuilder\CsvBuilder; $csvBuilder = new CsvBuilder();
Available methods
Change default destination path
setFilePath(<string>)
$csvBuilder->setFilePath('/path/to/file');
Change default file name
setFileName(<string>)
$csvBuilder->setFileName('/path/to/file');
Set row of titles (required)
setTitles(<array>)
$csvBuilder->setTitles([ 'Title 1', 'Title 2', 'Title 3', 'Title 4' ]);
Clear all rows
clearRows(<array>)
$csvBuilder->clearRows();
Add new row (required)
addRow(<array>)
$csvBuilder->addRow([ 'Column 1', 'Column 2', 'Column 3', 'Column 4', ]);
Build the csv file (required for download)
create()
$csvBuilder->create();
Download csv file
download()
$csvBuilder->download();
License
The MIT License (MIT). Please see LICENSE for more information.