PHP 8.6 deprecated the CSV methods on SplFileObject (fgetcsv(), fputcsv(), setCsvControl() and getCsvControl()) without adding anything to replace them. This RFC by Damian Jóźwiak fills that gap with a new, always-enabled ext/csv extension in the Csv\ namespace, ported from Gina Peter Banyard's girgias/csv extension and extended with file and stream support.
With the default settings, it follows RFC 4180, the CSV standard other CSV implementations follow. That means no escape character (quotes are escaped by doubling them), parsing that doesn't change with setlocale(), and multibyte delimiters and enclosures.
What it looks like
Here is reading a file today with the deprecated API:
$file = new SplFileObject('data.csv'); $file->setFlags(SplFileObject::READ_CSV); $file->setCsvControl(',', '"', ''); foreach ($file as $row) { // ... }
And with ext/csv:
foreach (Csv\LazyLaxCollection::createFromFile('data.csv') as $row) { // ... }
LazyLaxCollection reads rows lazily, so memory use tracks the longest row rather than the whole file. Writing works the same way. Csv\collection_to_file() takes any iterable of arrays, generators included, and writes one row at a time:
Csv\collection_to_file('out.csv', $rows);
There are also string helpers. Csv\row_to_array() parses one row, and Csv\array_to_row() formats one, which finally gives str_getcsv() an inverse without going through a php://memory stream. Csv\collection_to_buffer() and Csv\buffer_to_collection() handle whole documents and throw a ValueError when rows have different widths. A _lax variant allows that.
Parsing is strict, whatever delimiter or enclosure you pick. A quote inside an unquoted field, data after a closing quote, a quote that is never closed, or a stray CR or LF outside a quoted field all throw a ValueError instead of being guessed at. row_to_array() takes exactly one row, so anything after its line ending is an error too. Multibyte settings that could make a row read two ways, such as delimiter xy with enclosure xyx, are rejected with a ValueError before any parsing starts.
Nothing returns false. Bad arguments and input that breaks these rules throw ValueError, non-array rows throw TypeError, and I/O failures throw Error.
What it means for existing code
Nothing breaks. fgetcsv(), fputcsv(), str_getcsv() and the deprecated SplFileObject methods keep working as they do now. The only change is that Csv\ becomes a reserved namespace, so userland code declaring symbols there could conflict.
If you migrate, expect some behavior to differ from the old functions on purpose. An empty line parses as [''] instead of [null]. Stray quotes, which the old functions read as text, are now errors, and so is whitespace before a quoted field. The default line ending is "\r\n", so a file with plain \n line endings throws until you pass "\n". Writing is stricter too: a field must be null, a bool, int, float, string or backed enum. Arrays, resources and objects throw a TypeError, even Stringable ones that fputcsv() converts today, so you cast them yourself.
Where it stands
Damian Jóźwiak opened the internals discussion on October 9, 2026, the same day version 1.1 tightened the parsing rules after a review of the implementation. The RFC targets the next minor release after PHP 8.6. On the reviewer's benchmark, reading a file is no slower than fgetcsv(), and writing is 10 to 20 percent slower than fputcsv().
Two questions are still open: whether the extension can be disabled at build time, and what to call LazyLaxCollection and whether a strict lazy version should ship too. Version 1.2, published October 11, settled a third by rejecting ambiguous multibyte settings instead of writing data that can't be read back. Version 1.4, on November 10, added those type rules. The proposed vote needs a 2/3 majority.