Download the PHP package csvtoolkit/csv-helper without Composer
On this page you can find all versions of the php package csvtoolkit/csv-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download csvtoolkit/csv-helper
More information about csvtoolkit/csv-helper
Files in csvtoolkit/csv-helper
Package csv-helper
Short Description A PHP library for reading and writing CSV files with ease. CsvHelper supports custom delimiters, enclosures, and escape characters, providing flexible and efficient CSV data handling. It includes implementations using PHP's SplFileObject and other popular CSV libraries, ensuring compatibility with various CSV formats.
License MIT
Informations about the package csv-helper
CSV Toolkit
⚠️ Experimental Status: This library is currently in experimental phase. While it works correctly and passes all tests, please use with caution in production environments. We recommend thorough testing in your specific use case before deployment.
A modern, high-performance CSV processing library for PHP that automatically selects the best available implementation. CsvToolkit provides a unified interface for reading and writing CSV files, with automatic fallback between the FastCSV extension (when available) and PHP's built-in SplFileObject.
Features
- Automatic Implementation Selection: Automatically uses FastCSV extension when available, falls back to SplFileObject
- Unified Interface: Same API regardless of underlying implementation
- High Performance: FastCSV extension provides significant performance improvements
- Flexible Configuration: Support for custom delimiters, enclosures, escape characters, and headers
- Factory Pattern: Simple factory methods for creating readers and writers
- Action Classes: Convenient action classes for quick CSV operations
- Comprehensive Testing: Full test suite with 146+ tests covering both implementations
- Type Safety: Full type declarations and PHPDoc documentation
Installation
Install via Composer:
Optional: FastCSV Extension
For enhanced performance, install the FastCSV PHP extension:
Quick Start
Using Factory (Recommended)
Using Action Classes
Manual Implementation Selection
Configuration
Reading CSV Files
Writing CSV Files
Implementation Detection
Exception Handling
The library provides specific exceptions for different error conditions:
Performance
When the FastCSV extension is available, CsvToolkit provides significant performance improvements over PHP's native SplFileObject:
🚀 Benchmark Results (PHP 8.4.8, 1GB memory limit)
Read Operations:
- Small datasets (1K rows): 4.1x faster - 272K vs 67K records/sec
- Medium datasets (100K rows): 3.6x faster - 568K vs 156K records/sec
- Large datasets (1M rows): 4.8x faster - 503K vs 106K records/sec
Combined Read/Write Operations:
- Small datasets: 1.6x faster - 88K vs 56K records/sec
- Medium datasets: 2.5x faster - 339K vs 136K records/sec
- Large datasets: 2.9x faster - 282K vs 98K records/sec
💾 Memory Efficiency
- Constant memory usage: ~2MB regardless of file size
- Streaming operations: No memory accumulation with large files
- Real memory usage: Minimal (0 bytes) due to efficient streaming
📊 Performance Characteristics
- FastCSV: Optimized C extension with direct memory access
- SplFileObject: Pure PHP implementation with additional overhead
- Scaling: Performance advantage increases with data size
- Consistency: FastCSV shows lower standard deviation for predictable performance
🎯 Real-world Impact
- Lower development costs: Reduce time spent on CSV processing optimization
- Reduce infrastructure costs: More efficient processing means lower server resources
- Better scalability: Handle larger datasets without performance degradation
The library automatically selects the best available implementation without any code changes required.
Benchmark Details: Comprehensive performance validation available at benchmarking-php-fastcsv
Testing
Run the test suite:
Contributing
We welcome contributions! Please follow these guidelines:
- Respect all modern PHP coding standards and best practices
- Ensure that all methods include type declarations
- Pass all unit tests before committing your changes
- Tests are required for any new features or bug fixes
- Maintain compatibility with both FastCSV and SplFileObject implementations
Roadmap
Current Features ✅
- FastCSV extension integration with automatic fallback
- Factory pattern for implementation selection
- Action classes for convenient usage
- Comprehensive exception handling
- Full type safety and documentation
Requirements
- PHP 8.3 or higher
- Optional: FastCSV extension for enhanced performance
Support the Project
If you find CSV Toolkit useful for your projects, please consider sponsoring the development! Your support helps maintain and improve this high-performance CSV library while reducing development and infrastructure costs.
Why sponsor?
- 🚀 Accelerate development of new features
- 🐛 Faster bug fixes and improvements
- 📚 Better documentation and examples
- 🎯 Priority support for feature requests
- 💡 Fund research into even faster CSV processing techniques
- 💰 Lower development costs - Reduce your team's time spent on CSV processing optimization
- 🏗️ Reduce infrastructure costs - More efficient processing means lower server resources needed
License
This project is open source and available under the MIT License. See the LICENSE file for more information.