Skip to main content
FiQueLa supports ten file formats through dedicated stream classes. Each format is identified by a short key used in FQL syntax and in the Enum\Format enum.

Format table

json, yaml, and neon also accept raw strings via Stream\Provider::fromString(). All other formats require a file path.

Opening formats

You can open any format in three ways:
  1. Stream\Provider::fromFile() — auto-detects format from the file extension, or accepts an explicit Enum\Format.
  2. Direct class open() — call the class for the specific format directly.
  3. FQL string syntax — embed the format and path in an FQL FROM clause.
CSV supports format-specific parameters: encoding (default utf-8), delimiter (default ,), enclosure (default "), useHeader (default 1), and bom (default 0). Pass them via the FQL string syntax: csv(data.csv, "windows-1250", ";") or with named parameters such as csv(data.csv, enclosure: "'", bom: "1"). CSV is read and written with native PHP fgetcsv / fputcsv and detects UTF-8, UTF-16, and UTF-32 BOMs automatically.

Format-specific parameters

CSV, XML, and LOG accept additional configuration parameters.

CSV parameters

In FQL string syntax:
As of FiQueLa 3.0, CSV runs on native PHP primitives — the previous league/csv dependency has been dropped. Type coercion is lazy: cells stay as strings until a comparison or arithmetic operation requires a typed value, and empty cells satisfy IS NULL.

XML parameters

In FQL string syntax:

Empty XML elements

Empty leaf elements (<foo/> or <foo></foo>) surface as an empty string '', so SQL-style predicates work directly:
Elements with attributes (<foo id="1"/>) still expose their @attributes structure, mixed content (<foo id="1">text</foo>) still surfaces text under the value key, and populated leaves (<foo>text</foo>) still return their text content.
Prior to FiQueLa 3.0.1, empty leaf elements surfaced as an empty array [], which forced consumers to probe with IS ARRAY or is_array() to detect missing values. From 3.0.1 onward, they behave as empty strings — use IS NULL, = '', or IF(field IS NULL, …) instead.

Namespaced XML

Records mirror the document as written. Prefixed elements and attributes keep their prefix (g:id, g:price) and stay in document order. Elements in the default namespace (xmlns="…") appear once, like elements without a namespace.
A prefixed name contains :, so wrap it in backticks in FQL:
  • Namespace declarations (xmlns, xmlns:*) are not reported as attributes. xml:lang and xml:space stay under @attributes with their qualified name.
  • Internal DTD entities are expanded (&co; becomes Company & Co).
  • External entities are never loaded. A document that declares one throws UnexpectedValueException (“External XML entities are not supported”).
  • A malformed record throws UnexpectedValueException (“Unable to parse XML record: unexpected end of document.”).
Before FiQueLa 3.2.5, every child of an element in the default namespace appeared twice ('title' => ['T', 'T']), and prefixed elements were moved after the unprefixed ones. From 3.2.5 the XML reader builds records directly from XMLReader, which fixes both and reads large XML files roughly three times faster. Output for XML without namespaces is unchanged.

LOG parameters

Predefined profiles: In FQL string syntax:
Before FiQueLa 3.3.0, a custom pattern in an FQL FROM clause was dropped and every line was parsed with the default nginx_combined profile (each row had _error set to pattern mismatch). Upgrade to 3.3.0 or later if you use custom patterns in FQL.
Automatic value normalization:
  • status is cast to integer
  • time is converted to Y-m-d H:i:s format
  • %D (request time in microseconds) is converted to milliseconds
  • %r (request line) is split into method, path, and protocol fields
Special fields in every row:
Malformed log lines do not throw exceptions. Instead, they produce a row with _error containing the error message and _raw containing the original line. This allows you to filter or inspect bad lines with standard FQL conditions.

Directory provider

FQL\Stream\Dir is a special provider that treats a directory as its data source. It lets you query metadata about files recursively across a directory tree.
In FQL string syntax, use the dir format key: