elaitech / import
Elaitech Import Package - A comprehensive import workflow system for Laravel
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/elaitech/import
Requires
- php: ^8.4
- illuminate/console: ^12.0
- illuminate/database: ^12.0
- illuminate/http: ^12.0
- illuminate/queue: ^12.0
- illuminate/support: ^12.0
- league/flysystem-ftp: ^3.31
- league/flysystem-sftp-v3: ^3.31
- spatie/laravel-activitylog: ^4.11
- spatie/laravel-data: ^4.19
- spatie/laravel-view-models: ^1.6
- symfony/yaml: ^7.4
Requires (Dev)
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.5.3
This package is auto-updated.
Last update: 2026-02-16 02:11:41 UTC
README
A comprehensive, modular data import workflow engine for Laravel 12. Provides a full pipeline system for downloading, reading, filtering, mapping, transforming, and processing data from external sources β with execution tracking, scheduling, and a built-in dashboard.
Namespace:
Elaitech\Import
Requires: PHP 8.4+ Β· Laravel 12 Β·elaitech/data-mapper
π Table of Contents
- Installation
- Architecture
- Pipeline System
- Models
- Services
- Enums
- Configuration
- Extending
- Testing
- License
π Installation
As a local Composer package (recommended)
In your root composer.json, add the package as a path repository:
{
"repositories": [
{
"type": "path",
"url": "./packages/import",
"options": { "symlink": true }
}
],
"require": {
"elaitech/import": "@dev"
}
}
Then install:
composer update elaitech/import
Publishing Assets
# Publish configuration php artisan vendor:publish --tag=import-config # Publish migrations (optional β they auto-load) php artisan vendor:publish --tag=import-migrations # Run migrations php artisan migrate
π Architecture
src/
βββ ImportServiceProvider.php # Package bootstrap β registers all sub-providers
βββ Helpers.php # Global helper functions
β
βββ Models/ # Eloquent models (5)
β βββ ImportPipeline.php # Main pipeline definition
β βββ ImportPipelineConfig.php # Per-step JSON configuration
β βββ ImportPipelineExecution.php # Execution run records
β βββ ImportPipelineLog.php # Per-stage log entries
β βββ ImportPipelineTemplate.php # Reusable pipeline templates
β
βββ Contracts/ # Top-level interfaces
β βββ Repositories/ # Repository contracts
β βββ Services/ # Service contracts
β
βββ Enums/ # Backed enums (6)
β βββ ImportPipelineStatus.php # pending, running, completed, failed, cancelled
β βββ ImportPipelineFrequency.php # once, daily, weekly, monthly
β βββ ImportPipelineStep.php # 8 stepper steps
β βββ PipelineStage.php # Pipeline execution stages
β βββ PipelineStatus.php # active, inactive, needs_configuration
β βββ ImageDownloadMode.php # Image download strategies
β
βββ Services/
βββ Core/ # Shared infrastructure
β βββ Abstracts/ # Base abstract classes
β βββ Contracts/ # Shared interfaces (ServiceInterface, FactoryInterface)
β βββ DTOs/ # Shared data objects (FilterConfigurationData, etc.)
β βββ Exceptions/ # Custom exceptions (Filter, Reader, Downloader, etc.)
β βββ Operators/ # Operator definitions
β βββ Registry/ # Service registries
β βββ Cache/ # Caching strategies
β βββ Configuration/ # Configuration handling
β βββ Traits/ # HasOptions, ServiceTrait, etc.
β
βββ Downloader/ # Data source downloaders
β βββ Abstracts/ # AbstractDownloader base
β βββ Contracts/ # DownloaderInterface
β βββ Factories/ # DownloaderFactory
β βββ Implementations/
β βββ HttpDownloader.php # HTTP/HTTPS downloads
β βββ FtpDownloader.php # FTP downloads
β βββ SftpDownloader.php # SFTP downloads
β
βββ Reader/ # Data format readers
β βββ Abstracts/ # AbstractReader base
β βββ Contracts/ # ReaderInterface
β βββ Factories/ # ReaderFactory
β βββ Implementations/
β βββ CsvReader.php # CSV parsing
β βββ JsonReader.php # JSON parsing
β βββ XmlReader.php # XML parsing
β βββ YamlReader.php # YAML parsing
β
βββ Filter/ # Data filtering engine
β βββ Abstracts/ # AbstractFilterOperator (Template Method)
β βββ Contracts/ # FilterInterface, OperatorRegistryInterface, etc.
β βββ Extractors/ # DotNotationValueExtractor
β βββ Registry/ # OperatorRegistry
β βββ Validators/ # FilterValidator
β βββ Implementations/ # 17 filter operators
β
βββ Pipeline/ # Pipeline orchestration
β βββ Contracts/ # PipelineExecutionServiceInterface, etc.
β βββ DTOs/ # PipelineContext, StageResult, etc.
β βββ Factories/ # ImportPipelineConfigFactory
β βββ Orchestrators/ # Pipeline orchestrator
β βββ Pipes/ # 7 sequential pipes (see below)
β βββ Services/ # ExecutionService, SchedulingService, TestDataService
β βββ ValueObjects/ # Pipeline value objects
β βββ Implementations/ # Concrete implementations
β
βββ Prepare/ # Data preparation
β βββ Contracts/ # PrepareInterface
β βββ Services/ # Preparation services
β
βββ ImageDownloader/ # Image download handling
β
βββ ImportDashboard/ # Dashboard service & repository
β βββ ImportDashboardService.php
β βββ ImportPipelineRepository.php
β
βββ Jobs/ # Queue jobs (2)
β
βββ Providers/ # Sub-service providers (5)
βββ DownloaderServiceProvider.php
βββ ReaderServiceProvider.php
βββ FilterServiceProvider.php
βββ PrepareServiceProvider.php
βββ PipelineServiceProvider.php
π Pipeline System
Each import pipeline consists of 7 sequential pipes that process data in order:
βββββββββββββββ ββββββββββββ ββββββββββββββ ββββββββββββ
β 1. Download βββββΆβ 2. Read βββββΆβ 3. Filter βββββΆβ 4. Map β
βββββββββββββββ ββββββββββββ ββββββββββββββ ββββββββββββ
β
βββββββββββββββ ββββββββββββ ββββββββββββββββββ β
β 7. Save ββββββ6. Prepareββββββ5. Images Prep βββββββ
βββββββββββββββ ββββββββββββ ββββββββββββββββββ
Pipes
| # | Pipe | File | Description |
|---|---|---|---|
| 1 | DownloadPipe | Pipeline/Pipes/DownloadPipe.php |
Fetches raw data from HTTP, FTP, or SFTP sources |
| 2 | ReadPipe | Pipeline/Pipes/ReadPipe.php |
Parses raw data using configured reader (CSV/JSON/XML/YAML) |
| 3 | FilterPipe | Pipeline/Pipes/FilterPipe.php |
Applies filter rules with AND/OR logic to include/exclude rows |
| 4 | MapPipe | Pipeline/Pipes/MapPipe.php |
Maps source fields β target fields via elaitech/data-mapper |
| 5 | ImagesPreparePipe | Pipeline/Pipes/ImagesPreparePipe.php |
Processes image URLs β separators, index skipping, download modes |
| 6 | PreparePipe | Pipeline/Pipes/PreparePipe.php |
Final prep β category resolution, VIN/stock ID generation |
| 7 | SavePipe | Pipeline/Pipes/SavePipe.php |
Placeholder save β simulates create/update stats without persistence |
Pipeline Configuration Steps (Stepper)
Pipelines are configured through an 8-step stepper wizard:
| Order | Step | Enum Value | Description |
|---|---|---|---|
| 1 | Basic Info | basic-info |
Name, description, frequency, start time |
| 2 | Downloader Config | downloader-config |
Protocol, URL, auth credentials |
| 3 | Reader Config | reader-config |
Format, delimiter, encoding, root path |
| 4 | Filter Config | filter-config |
Filter rules with operators and logic |
| 5 | Mapper Config | mapper-config |
Field mappings with transformers |
| 6 | Images Prepare | images-prepare-config |
Image handling settings |
| 7 | Prepare Config | prepare-config |
Data preparation rules |
| 8 | Preview | preview |
Review full configuration and test output |
π Models
ImportPipeline
The core model representing an import pipeline definition.
| Field | Type | Description |
|---|---|---|
name |
string |
Pipeline display name |
description |
string |
Optional description |
target_id |
string |
Target identifier |
is_active |
boolean |
Whether the pipeline is enabled |
frequency |
ImportPipelineFrequency |
once, daily, weekly, monthly |
start_time |
datetime |
Scheduled start time |
last_executed_at |
datetime |
Last execution timestamp |
next_execution_at |
datetime |
Next scheduled execution |
created_by / updated_by |
int |
Audit tracking (auto-set) |
Relationships: config(), executions(), logs(), creator(), updater()
Scopes: active(), scheduled()
Accessors: status (computed: active / inactive / needs_configuration)
ImportPipelineConfig
Stores per-step JSON configuration. Each pipeline has multiple config entries (one per stepper step).
ImportPipelineExecution
Tracks execution runs with status, timing, and result data.
| Field | Type | Description |
|---|---|---|
status |
ImportPipelineStatus |
pending, running, completed, failed, cancelled |
started_at / completed_at |
datetime |
Timing brackets |
total_rows / processed_rows |
int |
Row counts |
success_rate |
decimal |
Percentage success |
processing_time |
decimal |
Execution time in seconds |
memory_usage |
int |
Memory consumed |
error_message |
string |
Failure details |
result_data |
array |
Detailed result payload |
Helper Methods: markAsRunning(), markAsCompleted(), markAsFailed(), markAsCancelled(), addLog()
ImportPipelineLog
Per-stage log entries with level, message, and context.
ImportPipelineTemplate
Reusable pipeline configuration templates for quick setup.
βοΈ Services
Downloader
| Implementation | Protocol | Key Features |
|---|---|---|
HttpDownloader |
HTTP/HTTPS | Headers, auth, SSL config, timeouts |
FtpDownloader |
FTP | Passive mode, directory listing |
SftpDownloader |
SFTP | Key-based auth, known hosts |
Reader
| Implementation | Format | Key Features |
|---|---|---|
CsvReader |
CSV | Delimiter, enclosure, escape, encoding, header row |
JsonReader |
JSON | Root path, nested object traversal |
XmlReader |
XML | Node path, attribute mapping |
YamlReader |
YAML | Root key extraction |
Filter (17 Operators)
Built using the Template Method pattern via AbstractFilterOperator:
| Category | Operators |
|---|---|
| Equality | equals, not_equals |
| String | contains, not_contains, starts_with, ends_with |
| Numeric | greater_than, less_than, between, not_between |
| Set | in, not_in |
| Pattern | regex, not_regex |
| Null | is_null, is_not_null |
Features:
- Dot-notation field access for nested data
- AND/OR logical grouping of rules
- Case-sensitive/insensitive matching
- Extensible via
AbstractFilterOperatorbase class
Pipeline Services
| Service | Description |
|---|---|
PipelineExecutionService |
Orchestrates full pipeline execution |
PipelineSchedulingService |
Handles scheduled pipeline runs |
PipelineTestDataService |
Provides test data for step testing |
ImportPipelineConfigFactory |
Creates/updates step configurations |
Dashboard Services
| Service | Description |
|---|---|
ImportDashboardService |
Business logic for the dashboard UI |
ImportPipelineRepository |
Data access layer for pipelines |
π Enums
ImportPipelineStatus
pending Β· running Β· completed Β· failed Β· cancelled
Methods: getLabel(), getDescription(), getColor(), isActive(), isFinished(), isSuccessful(), isFailed(), isCancelled()
ImportPipelineFrequency
once Β· daily Β· weekly Β· monthly
Methods: getLabel(), getDescription(), getOptions()
ImportPipelineStep
basic-info Β· downloader-config Β· reader-config Β· filter-config Β· mapper-config Β· images-prepare-config Β· prepare-config Β· preview
Methods: title(), description(), route(), order()
PipelineStage
Represents the runtime execution stage of a pipeline.
PipelineStatus
active Β· inactive Β· needs_configuration
ImageDownloadMode
Strategies for handling image downloads during pipeline execution.
βοΈ Configuration
The package publishes config/import-pipelines.php:
php artisan vendor:publish --tag=import-config
π§ Extending
Adding a Custom Downloader
- Create a class extending the abstract downloader
- Implement the required methods
- Register in
DownloaderServiceProvider
Adding a Custom Reader
- Extend the abstract reader
- Implement parsing logic
- Register in
ReaderServiceProvider
Adding a Custom Filter Operator
use Elaitech\Import\Services\Filter\Abstracts\AbstractFilterOperator; final class CustomOperator extends AbstractFilterOperator { public function getName(): string { return 'custom'; } public function getLabel(): string { return 'Custom Operator'; } public function getDescription(): string { return 'My custom filter logic'; } public function supportsValueType(mixed $value): bool { return true; } protected function doApply(mixed $dataValue, mixed $filterValue, array $options): bool { // Your logic here return $dataValue === $filterValue; } }
Register it in FilterServiceProvider:
$registry->register(new CustomOperator());
Implementing Real Persistence (SavePipe)
Replace the placeholder SavePipe with your domain-specific save logic:
// In your custom SavePipe: // 1. Receive prepared data from PreparePipe // 2. Create/update your product models // 3. Return statistics (created, updated, errors)
π§ͺ Testing
# From the package directory ./vendor/bin/phpunit # From the root project php artisan test
π¦ Dependencies
| Package | Version | Purpose |
|---|---|---|
illuminate/support |
^12.0 | Laravel framework support |
illuminate/database |
^12.0 | Eloquent ORM |
illuminate/http |
^12.0 | HTTP handling |
illuminate/queue |
^12.0 | Queue jobs |
illuminate/console |
^12.0 | Artisan commands |
spatie/laravel-activitylog |
^4.11 | Audit logging |
spatie/laravel-data |
^4.19 | Typed DTOs |
spatie/laravel-view-models |
^1.6 | View models |
league/flysystem-ftp |
^3.31 | FTP filesystem |
league/flysystem-sftp-v3 |
^3.31 | SFTP filesystem |
symfony/yaml |
^7.4 | YAML parsing |
π License
MIT β see LICENSE for details.