Developing a custom application or a SaaS, you may need to implement a module that can import a CSV file in the Laravel application, and every time you need to build this functionality from scratch.
The Problem with importing a CSV file
It takes a lot of time and effort to create an API that can have columns validation, and file format, handle large import files (e.g. 1M rows), and makes a UI that can provide the best end-user experience.
The best solution to import a CSV file in Laravel
- A Laravel package with great, tested and documented API together with UI Livewire and Blade components.
- An NPM package to provide UI for React, Vue 2/3.
Features
- Ease and flexible integration in any Laravel/React/Vue projects.
- Define columns with their validation rules
- Support format: .xls, .xlsx, .ods, and .csv
- Templates of imports.
- Styles customization.
- Listen for events: Import started, Import ended.
- Send notifications to the user when the import is ready.
Using it has to be very simple, just look at this piece of code:
Define an import in a PHP class:
class UsersImport extends ImportFly
{
public function columns(): array
{
return [
Column::make('first_name')->text()->required(),
Column::make('last_name')->text()->required(),
Column::make('email')->email()->required(),
Column::make('website')->url()->required()
];
}
}
And then render the import component:
<livewire:import-fly data="users" />
What is Import Fly?
Import Fly is a Laravel package that provides support for importing CSV files in the Laravel application. Import Fly is launching soon, join our waiting list to be notified when is released.