Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fiquela.io/llms.txt

Use this file to discover all available pages before exploring further.

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

KeyNameClassFileString
csvCSVFQL\Stream\CsvYesNo
xmlXMLFQL\Stream\XmlYesNo
xlsXLSXFQL\Stream\XlsYesNo
odsODSFQL\Stream\OdsYesNo
jsonFileJSON streamFQL\Stream\JsonStreamYesNo
ndJsonNewline-delimited JSONFQL\Stream\NDJsonYesNo
jsonJSON (json_decode)FQL\Stream\JsonYesYes
yamlYAMLFQL\Stream\YamlYesYes
neonNEONFQL\Stream\NeonYesYes
logHTTP Access LogFQL\Stream\AccessLogYesNo
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.
use FQL\Enum\Format;
use FQL\Stream;

// Auto-detect from extension
$csv = Stream\Provider::fromFile('products.csv');

// Explicit format
$csv = Stream\Provider::fromFile('data.txt', Format::CSV);

// Direct class
$csv = Stream\Csv::open('products.csv');

// With custom delimiter
$csv = Stream\Csv::openWithDelimiter('products.csv', ';');

$query = $csv->query()->selectAll()->from('*');
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

ParameterDefaultDescription
encodingutf-8Input file encoding. Any encoding accepted by iconv. Non-UTF-8 input is transcoded via a convert.iconv.<src>/UTF-8 PHP stream filter.
delimiter,Single-character field separator.
enclosure"Single-character field enclosure used by fgetcsv / fputcsv.
useHeader11 to treat the first row as column headers, 0 otherwise.
bom01 to emit a UTF-8 BOM when writing. The reader detects UTF-8, UTF-16 LE/BE, and UTF-32 LE/BE BOMs automatically and skips them.
In FQL string syntax:
-- Positional
FROM csv(data.csv, "windows-1250", ";")

-- Named
FROM csv(data.csv, encoding: "windows-1250", delimiter: ";", enclosure: "'", bom: "1")
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

ParameterDefaultDescription
encodingutf-8Input file encoding.
In FQL string syntax:
FROM xml(feed.xml, "windows-1250")

Empty XML elements

Empty leaf elements (<foo/> or <foo></foo>) surface as an empty string '', so SQL-style predicates work directly:
WHERE invoiceNumber IS NULL          -- matches empty <invoiceNumber/>
WHERE invoiceNumber = ''             -- matches empty <invoiceNumber/>
SELECT IF(invoiceNumber IS NULL, '', invoiceNumber) AS invoice
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.

LOG parameters

ParameterDefaultDescription
formatnginx_combinedLog format profile name or custom for a custom pattern.
patternCustom Apache log_format pattern string. Only used when format is custom.
Predefined profiles:
ProfilePattern
nginx_combined%h - %u [%t] "%r" %>s %b "%{Referer}i" "%{User-Agent}i" (default)
nginx_main%h - %u [%t] "%r" %>s %b
apache_combined%h %l %u [%t] "%r" %>s %b "%{Referer}i" "%{User-Agent}i"
apache_common%h %l %u [%t] "%r" %>s %b
In FQL string syntax:
-- Default profile (nginx_combined)
FROM log(access.log).*

-- Positional profile selection
FROM log(access.log, "apache_common").*

-- Named parameter profile selection
FROM log(access.log, format: "apache_common").*

-- Custom pattern
FROM log(access.log, format: "custom", pattern: "%h %l %u [%t] \"%r\" %>s %b").*
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:
FieldTypeDescription
_rawstringOriginal unparsed log line
_errorstring | nullnull on success, error message on parse failure
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.
use FQL\Stream;

$dir = Stream\Dir::open('./data');

$query = $dir->query()
    ->selectAll()
    ->from('*');
In FQL string syntax, use the dir format key:
SELECT *
FROM dir(./data).*