Download the PHP package elachagui/laravel-smart-importer without Composer

On this page you can find all versions of the php package elachagui/laravel-smart-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 laravel-smart-importer

Laravel Smart Importer

A production-ready Laravel package for importing XLSX and CSV files into Eloquent models with column mapping, validation, duplicate handling, relational imports, logging, chunking, and queue support.

Features

Requirements

Installation

Install the package via Composer:

Publish the configuration file:

Run the migrations:

Configuration

The configuration file config/smart-importer.php allows you to customize:

Basic Usage

Simple Import

With Duplicate Handling

With Field Transformers

Queue Processing

With Options

Preview File

Get File Headers

Relational Imports

The package supports importing data with all Laravel Eloquent relation types. This allows you to create related records, look up existing records for foreign keys, and sync many-to-many relationships during import.

Supported Relation Types

Relation Type Description Processing Phase
belongsTo Lookup/create parent record, set foreign key Before main model
hasOne Create single child record After main model
hasMany Create multiple child records After main model
belongsToMany Sync pivot table (many-to-many) After main model
morphOne Polymorphic one-to-one After main model
morphMany Polymorphic one-to-many After main model
morphTo Inverse polymorphic (set type + id) Before main model
morphToMany Polymorphic many-to-many After main model
morphedByMany Inverse polymorphic many-to-many After main model
hasOneThrough Through intermediate model After main model
hasManyThrough Through intermediate model After main model

BelongsTo Relations

Look up an existing parent record (or create it if missing) and automatically set the foreign key.

Composite Key Lookup:

HasOne / HasMany Relations

Create child records after the main model is saved.

Multiple Records from Delimited Column:

Multiple Records from JSON Column:

BelongsToMany Relations (Many-to-Many)

Sync pivot table relationships from a column containing multiple values.

Sync Modes:

Mode Behavior
sync Replace all existing relations with new ones
attach Add new relations without removing existing
toggle Toggle relations (add if missing, remove if present)
syncWithoutDetaching Add new relations, keep existing ones

Polymorphic Relations

MorphMany - Create polymorphic child records:

MorphTo - Set polymorphic parent:

MorphToMany - Polymorphic many-to-many:

Through Relations

Create records through an intermediate model.

Model-Defined Relations

Define relations directly in your model by implementing the importRelations() method:

Then import without specifying relations:

Combining Multiple Relations

Relation Configuration Reference

Option Type Description
type string Required. Relation type (belongsTo, hasMany, etc.)
model string Required. Related model class
file_column string Single file column to read from
file_columns array Multiple file columns (for composite keys)
lookup_by string Column to search by in related table
lookup_columns array Multiple columns for composite key lookup
create_if_missing bool Create related record if not found (default: false)
create_mapping array Column mapping when creating related record
mapping array Column mapping for hasOne/hasMany child records
defaults array Default values when creating records
foreign_key string Explicit foreign key column name
owner_key string Parent model's key column (default: 'id')
local_key string Local model's key column (default: 'id')
separator string Separator for parsing multiple values (default: ',')
sync_mode string For belongsToMany: sync, attach, toggle (default: 'sync')
pivot_data array Static data for pivot table
pivot_columns array Map file columns to pivot columns
morph_name string Morph name for polymorphic relations
morph_type_column string Morph type column name
morph_id_column string Morph ID column name
through_model string Intermediate model for through relations
first_key string First key for through relations
second_key string Second key for through relations
transformers array Field transformers for this relation

Implementing Importable Interface

For models with validation rules, implement the Importable interface:

Import Model

The package creates import records to track progress:

Cancelling Imports

Events

The package fires several events during the import lifecycle:

Event Data

Exception Handling

Example Controller

Testing

Security

The package includes security measures:

  1. Model Whitelist: Only models listed in allowed_models config can be imported
  2. File Validation: Only supported file types are processed
  3. Input Validation: All rows are validated before import

Performance Tips

  1. Use queue processing for large files
  2. Adjust chunk_size based on your server's memory
  3. Disable model events with withoutModelEvents() for faster imports
  4. Use batchInsert (default) instead of individual inserts
  5. For imports with hasMany/belongsToMany relations, records are inserted individually (not batched) to support relation processing

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-smart-importer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
illuminate/queue Version ^10.0|^11.0
illuminate/validation Version ^10.0|^11.0
illuminate/events Version ^10.0|^11.0
maatwebsite/excel Version ^3.1
league/csv Version ^9.0
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 elachagui/laravel-smart-importer contains the following files

Loading the files please wait ...