The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Getting Started

Connections Settings

Inserting Records

Selecting Records

Interoperability

Converting Records

Upgrading Guide

This is the documentation for the upcoming version 9.0. This is a work in progress

Overview

<?php

abstract class AbstractCsv implements ByteSequence
{
    public function __toString(): string
    public function addStreamFilter(string $filtername, mixed $params = null): self
    public function chunk(int $length): Generator
    public static function createFromFileObject(SplFileObject $obj): self
    public static function createFromPath(string $path, string $open_mode = 'r+', resource $context = null): self
    public static function createFromStream(resource $stream): self
    public static function createFromString(string $str): self
    public function hasStreamFilter(string $filtername): bool
    public function getDelimiter(): string
    public function getEnclosure(): string
    public function getEscape(): string
    public function getInputBOM(): string
    public function getOutputBOM(): string
    public function getStreamFilterMode(): int
    public function output(string $filename = null): int
    public function setDelimiter(string $delimiter): self
    public function setEnclosure(string $enclosure): self
    public function setEscape(string $escape): self
    public function setOutputBOM(): self
    public function supportsStreamFilter(): bool
}

Connection type

Accessing the CSV document is done using one of the following class:

Both classes extend the League\Csv\AbstractCsv class and as such share the following features:

OS specificity

If your CSV document was created or is read on a Macintosh computer, add the following lines before using the library to help PHP detect line ending in Mac OS X.

<?php

if (!ini_get("auto_detect_line_endings")) {
    ini_set("auto_detect_line_endings", '1');
}

//the rest of the code continues here...