PHPackages                             aaronbell1/laravel-csv-bulk-uploader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. aaronbell1/laravel-csv-bulk-uploader

ActiveLibrary[File &amp; Storage](/categories/file-storage)

aaronbell1/laravel-csv-bulk-uploader
====================================

v1.5(6y ago)1137MITPHP

Since Apr 15Pushed 6y agoCompare

[ Source](https://github.com/aaronbell1/laravel-csv-bulk-uploader)[ Packagist](https://packagist.org/packages/aaronbell1/laravel-csv-bulk-uploader)[ RSS](/packages/aaronbell1-laravel-csv-bulk-uploader/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (12)Used By (0)

Laravel CSV Bulk Uploader
=========================

[](#laravel-csv-bulk-uploader)

The bulk uploader is intended to allow users to have a simple way to validate and upload records from a CSV directly to database.

The package makes use of Laravel validators to validate the data, and Laravel DB object to commit records to the Database.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Creating bulk uploader](#creating-bulk-uploader)
- [Usage](#usage)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require aaronbell1/laravel-csv-bulk-uploader
```

If you are using Laravel &lt; 5.5, you will need to add the following to your `'providers'` array in `config/app.php`:

```
    Aaronbell1/LaravelCsvBulkUploader/LaravelCsvBulkUploaderServiceProvider::class,
```

Creating bulk uploader
----------------------

[](#creating-bulk-uploader)

To create a new uploader, from the command line enter:

```
php artisan make:uploader {name}
```

Where `{name}` is the class name e.g. 'UserBulkUploader'

This will generate the class within `app/Uploaders` folder.

There are 3 methods that are required to implement in your class:

- [`rules`](#rules)
- [`messages`](#messages)
- [`saveRow`](#saverow)

### rules

[](#rules)

The `rules()` method represents validation rules as per a [Laravel Form Request](https://laravel.com/docs/5.8/validation#form-request-validation).

This must return an array with the rules required for a single row of your CSV data. The field names are represented as a lowercase and underscored version of your column header value e.g. `User first name` would be `user_first_name`.

For example:

```
return [
    'firstname' => 'required',
    'email'     => 'required|email',
    'age'       => 'integer|min:18'
];
```

### messages

[](#messages)

The `messages()` method represents validation rule messages as per [Laravel Form Request Error Messages](https://laravel.com/docs/5.8/validation#customizing-the-error-messages).

For example, you could overwrite one of the above messages using:

```
return [
    'firstname.required' => 'User first name is required.',
    'age.min'            => 'User age must be at least 18.'
];
```

### saveRow

[](#saverow)

The `saveRow()` method is used to define how you process each row of data returned from the CSV.

The data is passed through as an array with the keys defined as the column headers converted to lowercase with underscores.

For example using the validation from above, you can access each row of data with:

```
$name = $row['firstname'];
$email = $row['email'];
```

Usage
-----

[](#usage)

In order to make use of the package you must ensure that you are using a `.csv` file with a header row that includes a unique name for each column.

In the controller where you need to use the bulk uploader, you can either inject an instance of the class:

```
protected $userUploader;

public function __construct(UserBulkUploader $userUploader)
{
    $this->userUploader = $userUploader;
}
```

or create a new instance of it:

```
public function store()
{
    $userUploader = new UserBulkUploader;
}
```

The uploader instance has the following methods:

- [`load`](#load)
- [`isValid`](#isvalid)
- [`save`](#save)
- [`redirectWithErrors`](#redirectwitherrors)

### load

[](#load)

The `load()` method accepts the path to the CSV file that you are working from.

```
public function store()
{
    $userUploader = new UserBulkUploader;
    $userUploader->load('/path/to/file.csv');
}
```

### isValid

[](#isvalid)

The `isValid()` method will use the rules as defined on the bulk uploader to check whether the CSV contains valid data.

This will return a boolean value.

```
public function store()
{
    $userUploader = new UserBulkUploader;
    $userUploader->load('/path/to/file.csv');
    $isValid = $userUploader->isValid();

    if($isValid) {
      // success
    } else {
      // failure
    }
}
```

If the data is not valid, you can easily [redirect back with the errors](#redirectwitherrors) to display them to the user as you require.

### save

[](#save)

The `save()` method will make use of the `saveRow()` method defined on the bulk uploader to process your data.

This works as a database transaction so if it encounters any errors it will rollback the transaction and throw an appropriate exception, otherwise if successful it will be committed.

```
public function store()
{
    $userUploader = new UserBulkUploader;
    $userUploader->load('/path/to/file.csv');
    $isValid = $userUploader->isValid();

    if($isValid) {
      $userUploader->save();
    } else {
      // failure
    }
}
```

### redirectWithErrors

[](#redirectwitherrors)

The `redirectWithErrors()` method will make use of [Laravel Redirects](https://laravel.com/docs/5.8/redirects) to redirect the user back to the previous page with any errors stored in the session.

The method accepts the name of the data array which by default is `data`.

You can make use of these errors in your blade file using the session helper:

```
// Controller.php
public function store()
{
    $userUploader = new UserBulkUploader;
    $userUploader->load('/path/to/file.csv');
    $isValid = $userUploader->isValid();

    if($isValid) {
      $userUploader->save();
    } else {
      return $userUploader->redirectWithErrors('users');
    }
}
```

```
// View.blade.php

// ERROR MESSAGES
@if ($errors->any())

        @foreach ($errors->unique() as $error)
            {{ $error }}
        @endforeach

@endif

// USERS WITH ERRORS
@foreach(session('users') as $key => $user)
    {{ $user['firstname'] }}
@endforeach
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity67

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~29 days

Recently: every ~73 days

Total

11

Last Release

2336d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2ba8e118c0a91ef160f5ca87bb87de87d4a90adb04ffb30bcde760ce9962e78?d=identicon)[aaronbell1](/maintainers/aaronbell1)

### Embed Badge

![Health badge](/badges/aaronbell1-laravel-csv-bulk-uploader/health.svg)

```
[![Health](https://phpackages.com/badges/aaronbell1-laravel-csv-bulk-uploader/health.svg)](https://phpackages.com/packages/aaronbell1-laravel-csv-bulk-uploader)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
