innovator-japan / laravel-csv
A library that manipulates CSV with Laravel
Installs: 3 259
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 7
Forks: 2
Open Issues: 2
Requires
- php: >=7.1.3
- ext-mbstring: *
- illuminate/support: 5.6.* || 5.7.* || 5.8.*
- league/csv: ^9.1.0
Requires (Dev)
- orchestra/testbench: ^3.7
- php-coveralls/php-coveralls: ^2.1
- phpmd/phpmd: ^2.6
- phpstan/phpstan: ^0.11.1
- phpstan/phpstan-phpunit: ^0.11.0
- phpstan/phpstan-strict-rules: ^0.11.0
- phpunit/phpunit: ^7.5
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-11-18 05:24:24 UTC
README
Features
- Easily export to csv from collection
- Highly memory efficient
- Wrapper around League\Csv
Requirements
- PHP 7.1.3 or later
- Laravel 5.6 or later
- mbstring extension
Installation
This project using composer.
$ composer require innovator-japan/laravel-csv
Usage
Exporting a database table as a CSV
1️⃣ First of all, Create this class.
<?php namespace App\Export; use App\User; use Illuminate\Database\Query\Builder; use InnovatorJapan\LaravelCsv\AbstractCsv; use InnovatorJapan\LaravelCsv\Exportable; class UserCsv extends AbstractCsv { use Exportable; public function query(): Builder { return User::latest()->getQuery(); } }
2️⃣ Then you will be able to download it.
use App\Export\UserCsv; use App\Http\Controllers\Controller; class UserController extends Controller { public function export() { return (new UserCsv())->download('user.csv'); } }
Importing CSV records into a database table
Comming soon...
Maintainers
Contributing
Please see CONTRIBUTING for details.
License
MIT © Innovator Japan Inc.