monokakure/laravel-csv

Simple CSV manipulation for Laravel. Also you can select encoding.

0.3.0 2015-04-22 07:13 UTC

This package is not auto-updated.

Last update: 2024-11-13 07:48:59 UTC


README

Simple CSV manipulation for Laravel. Also you can select encoding.

Getting started

Add to composer.json

'monokakure/laravel-csv': 'dev-master'

Install your composer

composer install

Add ServiceProvider to app.php

'Monokakure\CSV\CSVServiceProvider',

If you want, add Alias

'CSV'=> 'Monokakure\CSV\CSVFacade',

Usage

  • from array
CSV::create($arr, $header);
  • get CSV
CSV::create($arr, $header)->build();
  • You can select Encode
CSV::setEncode('SJIS-win', 'UTF-8')->create($arr, $header)->build();
  • You can put BOM
CSV::create($arr, $header)->setBOM_UTF8()->build();
CSV::create($arr, $header)->setBOM_UTF16LE()->build();
  • You can change delimiter
CSV::create($arr, $header)->setDelimiter("\t")->build();
  • get Response
CSV::create($arr, $header)->render();
  • parse CSV
CSV::parse('sample.csv');

Extend

If you want, you can use extended Monokakure\CSV\CSV class. Override Monokakure\CSV\Factory#getCSV method.