coderflex/laravel-csv
A Laravel livewire CSV Importer, to handle importing millions of rows without a hustle.
Installs: 75
Dependents: 0
Suggesters: 0
Security: 0
Stars: 64
Watchers: 2
Forks: 7
Open Issues: 5
pkg:composer/coderflex/laravel-csv
Requires
- php: ^8.1
- illuminate/contracts: ^9.0|^10.0
- league/csv: ^9.8
- livewire/livewire: ^2.10
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0|^7.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0|^8.0
- pestphp/pest: ^1.22
- pestphp/pest-plugin-laravel: ^1.1
- pestphp/pest-plugin-livewire: ^1.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5|^10.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 6292d07011ba19170f022efac0196acf89f93810
- ousid<oussama.woop@coderflex.com>
- dev-main
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/github_actions/actions/checkout-6
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-7
- dev-dependabot/github_actions/actions/checkout-5
- dev-dependabot/github_actions/dependabot/fetch-metadata-2.4.0
- dev-dependabot/github_actions/ramsey/composer-install-3
- dev-laravel-10-support
- dev-badges-fix
- dev-fix-ci-tests
This package is auto-updated.
Last update: 2025-11-24 12:14:51 UTC
README
- Introduction
- Installation
- Configuration
- Usage
- Testing
- Changelog
- Contributing
- Security Vulnerabilities
- Inspiration
- Credits
- License
Introduction
Laravel CSV Package is a package created on top of Laravellivewire for easily handling imports with a simple API.
Installation
You can install the package via composer:
composer require coderflex/laravel-csv
Configuration
Publish and run the migrations with:
php artisan vendor:publish --tag="csv-migrations"php artisan migrateAdd traitHasCsvImports to your User model.
Publish the config file with:
php artisan vendor:publish --tag="csv-config"The following is the contents of the published config file:
return [/* |-------------------------------------------------------------------------- | Default Layout |-------------------------------------------------------------------------- | | This package plans on supporting multiple CSS frameworks. | Currently, 'tailwindcss' is the default and only supported framework. | */'layout' =>'tailwindcss',/* |-------------------------------------------------------------------------- | Max Upload File Size |-------------------------------------------------------------------------- | | The default maximumum file size that can be imported by this | package is 20MB. If you wish to increase/decrease this value, | change the value in KB below. | */'file_upload_size' =>20000,];
Thelayout option is for choosing which CSS framework you are using and currently supports onlytailwindcss. We are working on other CSS frameworks to implement in the future.
Thefile_upload_size is for validation rules, and it defines the maximum file size of uploaded files. You may also define this value from thelivewire config file.
Optionally, you can publish the views using
php artisan vendor:publish --tag="laravel-csv-views"Before Using this command, please take a look at thissection below.
Usage
CSV Importer Component
Using this package is a breeze. To implement the importer in your project, simply include the following component inside a Blade view.
<livewire:csv-importer:model="App\Models\YourModel::class":columns-to-map="['id', 'name', 'email', 'password']":required-columns="['id', 'name', 'email']":columns-label="[ 'id' => 'ID', 'name' => 'Name', 'email' => 'Email Address', 'password' => 'Password', ]"/>
| Props | Type | Description |
|---|---|---|
| model | string | Fully qualified name of the model you wish to import to |
| columns-to-map | array | Column names in the target database table |
| required-columns | array | Columns that are required by validation for import |
| columns-label | array | Display labels for the required columns |
Button Component
The Component usesalpinejs under the hood. To display an import button, include thex-csv-button component.
<x-csv-button>Import</x-csv-button>
To style the button, use theclass attribute with Tailwind utility classes.
<x-csv-buttonclass="rounded py-2 px-3 bg-indigo-500 ..."type="button"....>{{__('Import')}}</x-csv-button>
In TALL stack project
If you are using this package in aTALL Stack project, (Tailwindcss, Alpinejs, Laravel, Livewire) publish the vendor views to include Laravel-CSV in your project.
php artisan vendor:publish --tag="csv-views"Then compile your assets.
npm run dev
In none TALL Stack project
If you are not using the TALL Stack, use thecsv directives to add the necessary styles/scripts.
<html> ... <head> ...@csvStyles </head> ... <footer> ...@csvScripts </footer></html>
Using Queues
This package usesqueues under the hood withPHP Generators to make it fast and efficient.
Create thebatches table by running
php artisan queue:batches-table
Then, run the migration.
php artisan migrateAfter that, set up the queues' configuration.Head toLaravel Queues Documentation to learn more.
Testing
composertestChangelog
Please seeCHANGELOG for more information on what has changed recently.
Contributing
Please seeCONTRIBUTING for details.
Security Vulnerabilities
Please reviewour security policy on how to report security vulnerabilities.
Inspiration
This Package Was Inspired bycodecourse video series. If you want to learn how this package was created, make sure to take a look at thisvideo series
Credits
License
The MIT License (MIT). Please seeLicense File for more information.
