hybrideconseil / csv-laravel
CSV manipulation for Laravel.
0.4.0
2019-12-26 09:24 UTC
Requires
- php: ^7.4
- ext-mbstring: *
- laravel/framework: ^6.9.0
Requires (Dev)
- laravel/laravel: ^6.0
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-11-27 19:43:43 UTC
README
CSV manipulation for Laravel 6+.
Getting started
Add it to composer.json
'hybrideconseil/csv': '0.4.0'
Install it
composer install
Add ServiceProvider to app.php
'HybrideConseil\CSV\CSVServiceProvider',
If you want, add an alias
'CSV' => 'HybrideConseil\CSV\CSVFacade',
Usage
- create from array:
CSV::create($array, $header);
- get CSV content:
CSV::create($array, $header)->build();
- change encoding:
CSV::setEncode('SJIS-win', 'UTF-8')->create($array, $header)->build();
- add BOM:
CSV::create($array, $header)->setBOM_UTF8()->build();
CSV::create($array, $header)->setBOM_UTF16LE()->build();
- set delimiter:
CSV::create($array, $header)->setDelimiter("\t")->build();
- get CSV content:
CSV::create($array, $header)->render();
- read (parse) CSV file:
CSV::parse('sample.csv');