Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clivern/laravel-csv-export
:mag_right: Export a Large Dataset in CSV Format.
https://github.com/clivern/laravel-csv-export
csv csv-format dataset export laravel laravel-5-package laravel-csv-export
Last synced: about 2 months ago
JSON representation
:mag_right: Export a Large Dataset in CSV Format.
- Host: GitHub
- URL: https://github.com/clivern/laravel-csv-export
- Owner: Clivern
- License: mit
- Created: 2016-11-04T23:08:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T20:27:32.000Z (11 months ago)
- Last Synced: 2024-11-12T20:48:44.773Z (about 2 months ago)
- Topics: csv, csv-format, dataset, export, laravel, laravel-5-package, laravel-csv-export
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel CSV Export
Export a Large Dataset in CSV Format. It is based on Symfony’s StreamedResponse and Laravel’s chunked queries.
*Current version: [v1.0.4]*
## Installation
Via Composer
``` bash
$ composer require clivern/lce
```Then add the ServiceProvider to the providers array in `config/app.php`
```php
'providers' => [
// ...
Clivern\Lce\LceServiceProvider::class,
// ...
],
```You can use the facade for shorter code. Add this to your aliases:
```php
'aliases' => [
// ...
'Lce' => Clivern\Lce\Facades\Lce::class,
// ...
],
```The class is bound to the ioC as `lce`
```php
$lce = App::make('lce');
```## Usage
For Example Let's use it to export options table.
``` php
namespace App\Http\Controllers;use App\Http\Controllers\Controller;
use App\Models\Option; # Eloquent Model
use Validator;
use Input;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;class HomeController extends Controller
{public function indexRender()
{return \App::make('lce')
->file('options')
->source(new Option)
->chunks(10)
->header([["Id","Option Key","Option Value"], ['', '', '']])->callback(function($option){
return [
$option->id,
$option->op_key,
$option->op_value,
];
})->export();
}
}
```## Change log
```
Version 1.0.4:
> Composer lock file added.Version 1.0.3:
> New method to get CSV file content.
> New feature to add two rows in single return.Version 1.0.2:
> Docs Updated.Version 1.0.1:
> Docs Updated.
> UTF-8 Support Added.Version 1.0.0:
> Initial Release.
```## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.