Skip to main content
This guide shows three ways to open a file and run a query. All approaches produce the same result — choose the one that fits your style.
1

Install FiQueLa

If you haven’t already, add the package to your project:
Then include the autoloader:
2

Approach 1: Open a file with Stream\Provider

Use Stream\Provider::fromFile to open a file and call ->query() to start building a query with the fluent API. The format is inferred automatically from the file extension.
You can also open specific stream classes directly:
Pass an explicit Enum\Format constant as the second argument to fromFile when the extension is ambiguous or missing: Stream\Provider::fromFile('./data', Enum\Format::XML).
3

Approach 2: FileQuery syntax with Query\Provider

Query\Provider::fromFileQuery accepts a compact string that encodes the format, file path, and data path in one expression. This is useful for quick one-liners.
The FileQuery string format is:
Examples:
4

Approach 3: FQL string syntax with Query\Provider

Query\Provider::fql accepts a full SQL-like string. This is the most expressive option and mirrors the FQL syntax closely.
5

Inspect the output

All three approaches produce the same array structure:
fetchAll() returns a Generator. Wrap it with iterator_to_array() to get a plain array, or iterate it directly in a foreach loop.

Next steps

Fluent API

Learn every method available for building queries in PHP.

FQL syntax

Write full SQL-like query strings with all supported clauses.