talira

League CSV

PHP library for reading, writing and querying CSV documents

open sourceMITfree

League CSV (league/csv) is a PHP library for parsing, writing and filtering CSV, from The League of Extraordinary Packages. It reads and writes CSV documents in a memory-efficient way, queries them and maps rows to objects, converts them to JSON, XML or HTML, and supports PHP stream filters. It's framework-agnostic, uses PHP's native features where it can, and needs the ext-filter extension. Version 9.30 and later need PHP 8.3.

Problems it solves

  • read a large CSV file in PHP without loading it all into memory
  • export database rows to a CSV download in PHP
  • filter and map the rows of a CSV file to objects in PHP

Features

  • memory-efficient reading and writing of CSV
  • query features and array-to-object mapping
  • conversion to JSON, XML or HTML
  • PHP stream filter support
  • framework-agnostic

Limitations

  • From PHP 8.6, using it with SplFileObject or SplTempFileObject instances triggers deprecation notices.1