PHPackages                             onlyphp/codeigniter3-csvimporter - 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. [Database &amp; ORM](/categories/database)
4. /
5. onlyphp/codeigniter3-csvimporter

ActiveLibrary[Database &amp; ORM](/categories/database)

onlyphp/codeigniter3-csvimporter
================================

A robust CSV importer library for CodeIgniter 3 with background processing support, progress tracking, and detailed statistics. Perfect for handling large CSV files without timeouts or memory issues.

1.0.9(1y ago)027MITPHPPHP &gt;=8.0

Since Jan 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/faizzul95/Codeigniter3CSVImporter)[ Packagist](https://packagist.org/packages/onlyphp/codeigniter3-csvimporter)[ RSS](/packages/onlyphp-codeigniter3-csvimporter/feed)WikiDiscussions main Synced 1mo ago

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

CodeIgniter 3 CSV Importer 📊
============================

[](#codeigniter-3-csv-importer-)

[![Latest Version](https://camo.githubusercontent.com/20eedba47f9f7227af42fa789f8c4545a617d67e08ccff96f19f632f6a5868c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e6c797068702f636f646569676e69746572332d637376696d706f727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/onlyphp/codeigniter3-csvimporter)[![Total Downloads](https://camo.githubusercontent.com/3f960f9a3d88ae61b01416af517922192bfb70b17b88ef494a6ce47deaad4aa2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e6c797068702f636f646569676e69746572332d637376696d706f727465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/onlyphp/codeigniter3-csvimporter)[![License](https://camo.githubusercontent.com/6ecbbdea066a74ebdf7afd0cb13f00295fa46c0979d6f7a28809a9cd06b474c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6e6c797068702f636f646569676e69746572332d637376696d706f727465722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A robust CSV importer library for CodeIgniter 3 with background processing support, progress tracking, and detailed statistics. Perfect for handling large CSV files without timeouts or memory issues.

⚠️ Warning
----------

[](#️-warning)

**DO NOT USE THIS PACKAGE IN PRODUCTION**

This package is under active development and may contain critical bugs. It is primarily intended for personal use and testing. The current version has not undergone rigorous testing and may be unstable.

✨ Features
----------

[](#-features)

- 🚀 Background processing support with OS-specific optimizations
- 📊 Real-time progress tracking
- 📈 Detailed statistics (inserts/updates/errors)
- ⚠️ Comprehensive error handling
- 💻 Shared hosting compatible &amp; Cross-platform compatible (Windows &amp; Linux)
- ⏰ No cron job required
- 🛠️ Customizable processing logic
- 🔄 Memory-efficient chunk processing
- ⚡ Configurable processing parameters
- 📝 Skip empty rows automatically
- 🔍 Detailed error tracking
- 🖥️ Smart CPU load management
- 🔄 Automatic process recovery
- 🛡️ Process locking mechanism

🔧 System Requirements
---------------------

[](#-system-requirements)

- PHP 8.0 or higher
- CodeIgniter 3.x
- `proc_open` and `proc_close` PHP functions enabled
- `MySQL` database
- Write permissions for temporary directory
- For Linux: `mpstat` command available for CPU monitoring
- For Windows: `wmic` command available for CPU monitoring

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require onlyphp/codeigniter3-csvimporter
```

📝 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

```
// Initialize the processor
$processor = new \OnlyPHP\CSVSimpleImporter\CSVImportProcessor();

// Set callback function for processing each row
$processor->setCallback(function($row, $rowIndex, $models) {
    try {
        // Process your row data here
        return [
            'code' => 200,
            'action' => 'create',
            'message' => 'Success'
        ];
    } catch (\Exception $e) {
        return [
            'code' => 500,
            'error' => $e->getMessage()
        ];
    }
});

// Start processing
$jobId = $processor->process('/path/to/your/file.csv');
```

### Advanced Configuration

[](#advanced-configuration)

```
$processor = new \OnlyPHP\CSVSimpleImporter\CSVImportProcessor();

// Set user ID for file ownership
$processor->setFileBelongsTo(1);

// Set HTML element ID for frontend progress tracking
$processor->setDisplayHTMLId('progress-bar-1');

// Configure CSV processing parameters
$processor->setMemoryLimit('1G')
         ->setDelimiter(',')
         ->setEnclosure('"')
         ->setEscape('\\')
         ->setChunkSize(1000)
         ->setRecordUpdateInterval(250)
         ->setSkipHeader(true);

// Load specific models for processing
$processor->setCallbackModel(['User_model', 'Product_model']);

// Set callback with loaded models
$processor->setCallback(function($row, $rowIndex, $models) {
    $userModel = $models['User_model'];
    $productModel = $models['Product_model'];

    try {
        // Your processing logic here
        $result = $userModel->createFromCSV($row);

        return [
            'code' => 200,
            'action' => 'create',
            'message' => 'User created successfully'
        ];
    } catch (\Exception $e) {
        return [
            'code' => 500,
            'error' => 'Row ' . $rowIndex . ': ' . $e->getMessage()
        ];
    }
});

// Start processing
$jobId = $processor->process('/path/to/your/encryptFileName.csv', 'originalFileName.csv');
```

### Configuration Options

[](#configuration-options)

MethodDescriptionDefault`setMemoryLimit()`Set PHP memory limit for processing'1G'`setDelimiter()`Set CSV delimiter character','`setEnclosure()`Set CSV enclosure character'"'`setEscape()`Set CSV escape character'\\'`setChunkSize()`Set number of rows to process in each chunk1000`setRecordUpdateInterval()`Set database update interval (min 100)200`setSkipHeader()`Set whether to skip the header rowtrue### Process Control

[](#process-control)

```
// Kill a running process
$processor->killProcess($jobId);

// Check process status
$status = $processor->getStatus($jobId);

// Check status for all processes owned by a user
$status = $processor->getStatusByOwner($userId);
```

### Status Response Format

[](#status-response-format)

```
[
    'job_id' => 'csv_123456789',
    'total_process' => 100,
    'total_success' => 95,
    'total_failed' => 5,
    'total_inserted' => 80,
    'total_updated' => 15,
    'total_skip_empty_row' => 3,
    'display_id' => 'progress-bar-1',
    'estimate_time' => [
        'hours' => 0,
        'minutes' => 5,
        'seconds' => 30
    ],
    'file_name' => 'users.csv',
    'status' => 2, // 1=Pending, 2=Processing, 3=Completed, 4=Failed
    'error_message' => '[]',
    'percentage_completion' => '10',
    'last_check' => '2024-01-05 12:34:56'
]
```

### Frontend Integration Example

[](#frontend-integration-example)

```
function checkProgress(jobId) {
  $.ajax({
    url: "/your-controller/check-progress",
    data: { job_id: jobId },
    success: function (response) {
      if (response.status == 3) {
        // Process completed
        $("#progress-bar-1").html("Import completed!");
      } else if (response.status == 4) {
        // Process failed
        $("#progress-bar-1").html("Import failed: " + response.error_message);
      } else {
        // Update progress
        let progress = response.percentage_completion;
        $("#progress-bar-1").css("width", progress + "%");
        $("#progress-bar-1").html(`${progress}% (${response.total_success} succeeded, ${response.total_failed} failed)`);

        // Check again in 2 seconds
        setTimeout(() => checkProgress(jobId), 2000);
      }
    },
  });
}
```

📊 Status Codes Reference
------------------------

[](#-status-codes-reference)

CodeStatusDescription1PendingJob created, waiting to start2ProcessingCurrently processing the file3CompletedProcessing finished successfully4FailedProcessing encountered an error⚙️ Callback Response Format
---------------------------

[](#️-callback-response-format)

The callback function should return an array with the following structure:

```
// Success response
return [
    'code' => 200,
    'action' => 'create', // or 'update'
    'message' => 'Success message'
];

// Error response
return [
    'code' => 500,
    'error' => 'Error message'
];
```

🔒 Process Management Features
-----------------------------

[](#-process-management-features)

### CPU Load Management

[](#cpu-load-management)

The system automatically monitors server CPU load and manages processes accordingly:

- Delays process start if CPU load is above 90%
- Continuously monitors load during processing
- Platform-specific CPU monitoring (Linux uses `mpstat`, Windows uses `wmic`)

### Process Recovery

[](#process-recovery)

- Automatic cleanup of orphaned processes
- Lock file management to prevent duplicate processing
- Graceful handling of interrupted processes

### Memory Management

[](#memory-management)

- Chunk-based processing to control memory usage
- Configurable memory limits
- Automatic garbage collection
- Database connection management to prevent leaks

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](license.md) for more information.

💖 Support
---------

[](#-support)

If you find this library helpful, please consider giving it a star on GitHub!

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance42

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~2 days

Total

10

Last Release

478d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/55aa2d560832706c4e1025fd6552a5b1067eb56e60982e743a93490e8262fcf7?d=identicon)[faizzul95](/maintainers/faizzul95)

---

Top Contributors

[![faizzul95](https://avatars.githubusercontent.com/u/20121045?v=4)](https://github.com/faizzul95 "faizzul95 (13 commits)")

---

Tags

mysqlcodeignitercodeigniter3

### Embed Badge

![Health badge](/badges/onlyphp-codeigniter3-csvimporter/health.svg)

```
[![Health](https://phpackages.com/badges/onlyphp-codeigniter3-csvimporter/health.svg)](https://phpackages.com/packages/onlyphp-codeigniter3-csvimporter)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k25.2M34](/packages/kirschbaum-development-eloquent-power-joins)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58723.9M36](/packages/scienta-doctrine-json-functions)[cytopia/mysqldump-secure

Secure mysqldump script with encryption, compression, logging, blacklisting and Nagios monitoring integration

1474.7k1](/packages/cytopia-mysqldump-secure)[rougin/refinery

"Ready-to-eat" Codeigniter 3 migrations.

183.8k](/packages/rougin-refinery)

PHPackages © 2026

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