Download the PHP package langleyfoxall/eloquent-csv-importer without Composer

On this page you can find all versions of the php package langleyfoxall/eloquent-csv-importer. 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 eloquent-csv-importer

💾 Eloquent CSV Importer

Travis Status

Eloquent CSV Importer helps create and store column maps to enable the easy conversion of CSV data to Eloquent models

Installation

Eloquent CSV Importer can be easily installed using Composer. Just run the following command from the root of your project.

The service provider is to set to be auto discovered in Laravel 5.5+ - in older versions you will have to manually register it in config/app.php

After this, publish the vendor files to copy the CSV definitions migrations to your migrations folder.

Documentation

Getting started

  1. Publish the migrations, add any additional columns to the csv_defintions table you may want & migrate.

  2. Add the CSVMappable & HasCSVDefinitions traits to the model you want to store CSV definitions agaisnt.

  3. Specify the columns that you want to be allowed to be mapped by overriding the getCSVMappableColumns() function, by default it uses all the columns of the model.

  4. Create a CSV definition for your model you want to map to

  5. You can now use the created definition to convert CSV files / strings into the related models.

Updating by columns

Eloquent CSV Importer allows not only the creation of models from a CSV but the updating of models based on specified keys in the CSV.

Lets say you have the follow CSV:

product ID price
product-001 12.99
product-002 13.99

And the following code to map your CSV file into your models

The above code will now update or create a product model by finding a product where product_name is equal to the value in the current CSV row or by creating a new one with the data in the current CSV row if one doesn't already exist.

You can pass in multiple keys to update like so:

This will update an existing product where both values in the product are equal to the specified values in the CSV row.

Data item manipulation

If you wish, you can manipulate the data as it is being imported from the CSV. To do this, you must create a new a data item manipulator function, and then set it against the CSV definition.

The data item manipulator function will receive the data item key, value, and a copy of the entire row from the CSV. After making changes, it should return the modified data item value.

The example below converts any value it receives to uppercase.

The data item manipulator should be set before you call the makeModels or createModels methods.


All versions of eloquent-csv-importer with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0.0
illuminate/support Version >=5.0
illuminate/database Version >=5.0
illuminate/http Version >=5.0
league/csv Version ^9.1
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 langleyfoxall/eloquent-csv-importer contains the following files

Loading the files please wait ....