Skip to main content

Overview

Namespace: FQL\Stream Stream\Provider opens a data file or an in-memory string and returns a stream object. Each stream implements Interface\Stream and exposes a query() method that returns a Query ready to run against that stream. You rarely need to call stream classes directly — Query\Provider::fromFile() wraps Stream\Provider automatically. Use Stream\Provider directly when you need to configure the stream (e.g. set a custom CSV delimiter) before building a query.

Stream\Provider static methods

fromFile()

Open a file and return the matching stream object. The format is detected from the file extension unless $format is provided.
string
required
Absolute or relative path to the data file.
FQL\Enum\Format | null
Override the auto-detected format.
FQL\Interface\Stream
A concrete stream instance (e.g. Json, Csv, Xml).
Throws: FileNotFoundException, InvalidFormatException

fromString()

Create a stream from an in-memory string. Supported formats: JSON, YAML, NEON.
string
required
The raw string content to parse.
FQL\Enum\Format
required
The format of the string content. Must be Format::JSON, Format::YAML, or Format::NEON.
FQL\Interface\Stream
A stream wrapping the parsed string.
Throws: InvalidFormatException for unsupported formats (e.g. XML, CSV).

Stream classes

Each stream class can also be instantiated directly via its static open() method. After obtaining a stream instance, call ->query() to get a Query.

Xml

Class: FQL\Stream\Xml
Formats: .xml
For XML files with non-UTF-8 encoding, call ->setInputEncoding('windows-1250') on the stream before calling ->query().

Json

Class: FQL\Stream\Json
Formats: .json (full in-memory parse)
Loads the entire JSON file into memory. Use JsonStream for large files.

JsonStream

Class: FQL\Stream\JsonStream
Formats: .json (streaming, lazy)
Streams large JSON files row-by-row without loading the entire file into memory.

NDJson

Class: FQL\Stream\NDJson
Formats: .ndjson (Newline Delimited JSON)
Each line in the file must be a valid JSON object.

Csv

Class: FQL\Stream\Csv
Formats: .csv, .tsv
string
required
Path to the CSV file.
The CSV reader is built on native PHP fgetcsv (no third-party dependency) and accepts the parameters listed below. Defaults are applied when a parameter is omitted. To use a custom delimiter directly, call openWithDelimiter(). For full control over encoding, enclosure, header handling, and BOM, use a FileQuery string.

Yaml

Class: FQL\Stream\Yaml
Formats: .yaml, .yml

Neon

Class: FQL\Stream\Neon
Formats: .neon
NEON is the configuration format used by the Nette framework.

Xls

Class: FQL\Stream\Xls
Formats: .xlsx
Opens an Excel spreadsheet. Only the modern .xlsx format (Office Open XML) is supported. Legacy .xls (Excel 97–2003 binary format) is no longer supported — convert old files to .xlsx first.

Ods

Class: FQL\Stream\Ods
Formats: .ods

AccessLog

Class: FQL\Stream\AccessLog
Formats: .log
Reads HTTP server access log files line by line. Each line is parsed according to a predefined profile or a custom Apache log_format pattern.
setFormat(string $format): void — Sets the active log profile. Accepts nginx_combined (default), nginx_main, apache_combined, apache_common, or custom (requires a setPattern() call). setPattern(string $pattern): void — Sets a custom Apache log_format pattern. Only effective when the format is custom. Predefined profiles: Special fields in every row:
AccessLog does not support string() — only file-based input via open(). Malformed log lines produce a row with the _error field set instead of throwing an exception.

Dir

Class: FQL\Stream\Dir
Formats: dir
Treats a directory as a data source. Each file in the directory becomes a row.

query() method

All stream classes inherit query() from AbstractStream.
Returns a fresh Query bound to this stream. See the Query\Provider reference for the full fluent API.