Download the PHP package aaronbell1/laravel-csv-bulk-uploader without Composer

On this page you can find all versions of the php package aaronbell1/laravel-csv-bulk-uploader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package 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

Installation

You can install the package via composer:

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

Creating bulk uploader

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

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

The rules() method represents validation rules as per a Laravel Form Request.

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:

messages

The messages() method represents validation rule messages as per Laravel Form Request Error Messages.

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

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:

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:

or create a new instance of it:

The uploader instance has the following methods:

load

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

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.

If the data is not valid, you can easily redirect back with the errors to display them to the user as you require.

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.

redirectWithErrors

The redirectWithErrors() method will make use of Laravel 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:


All versions of laravel-csv-bulk-uploader with dependencies

PHP Build Version
Package Version
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aaronbell1/laravel-csv-bulk-uploader contains the following files

Loading the files please wait ....