pingpong / csv-reader
Laravel 4 - Csv Reader
Installs: 21 099
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 5
Open Issues: 1
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
Requires (Dev)
- mockery/mockery: 0.9.*
- phpunit/phpunit: 4.1.*
This package is not auto-updated.
Last update: 2024-11-22 11:18:54 UTC
README
Server Requirement
This package is require PHP 5.4 or higher.
Installation
Open your composer.json file, and add the new required package.
"pingpong/csv-reader": "1.0.*"
Next, open a terminal and run.
composer update
Next, Add new aliases in app/config/app.php.
'CsvReader' => 'Pingpong\CsvReader\Facades\CsvReader',
Done.
Usage
Create new instance.
$path = app_path('file.csv'); $csv = CsvReader::get($path); // OR $csv = CsvReader::make($path);
Get data.
$data = $csv->getData();
Get data as array.
$data = $csv->toArray();
Get data as json.
$data = $csv->toJson();
Get data as object.
$data = $csv->toObject();
Looping.
foreach($csv as $item) { var_dump($item); }
Without Laravel
Basically all functions and APIs same as above.
$path = __DIR__ . '/path/to/csvfile.csv'; $csv = new Pingpong\CsvReader\CsvReader($path); $data = $csv->getData();
License
This package is open-sourced software licensed under The BSD 3-Clause License