PHPackages                             gosuperscript/schema-lookup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. gosuperscript/schema-lookup

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

gosuperscript/schema-lookup
===========================

A PHP library for querying CSV/TSV files with streaming, dynamic filtering, aggregate functions, and range-based banding.

v0.4.5(2mo ago)0117[2 PRs](https://github.com/gosuperscript/axiom-lookup/pulls)proprietaryPHPPHP ^8.4CI passing

Since Jan 19Pushed 2mo agoCompare

[ Source](https://github.com/gosuperscript/axiom-lookup)[ Packagist](https://packagist.org/packages/gosuperscript/schema-lookup)[ RSS](/packages/gosuperscript-schema-lookup/feed)WikiDiscussions main Synced today

READMEChangelog (9)Dependencies (20)Versions (17)Used By (0)

Lookup Resolver
===============

[](#lookup-resolver)

A high-performance PHP library for querying CSV/TSV files with streaming, dynamic filtering, aggregate functions, and range-based banding.

Features
--------

[](#features)

- **Memory-Efficient Streaming**: O(1) memory complexity - processes records one-at-a-time
- **Seven Aggregate Functions**: `first`, `last`, `min`, `max`, `count`, `sum`, `avg`, `all`
- **Explicit Filter API**: `ValueFilter` and `RangeFilter` for clear, self-documenting code
- **Range-Based Banding**: Support for scenarios like tax brackets, premium tiers, shipping rates
- **Dynamic Filter Resolution**: Use nested lookups and symbols as filter values
- **Strongly-Typed Value Objects**: Enhanced type safety with immutable aggregates
- **Early Exit Optimization**: `first` aggregate stops reading after first match (465x faster)
- **Flexible Storage**: Support for local files, S3, and other storage backends via Flysystem
- **PHP 8.4 Compatible**: Full compatibility with latest PHP features

Installation
------------

[](#installation)

```
composer require gosuperscript/axiom-lookup
```

Quick Start
-----------

[](#quick-start)

```
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use Superscript\Axiom\Expression;
use Superscript\Axiom\Lookup\{LookupResolver, LookupSource};
use Superscript\Axiom\Lookup\Support\Filters\ValueFilter;
use Superscript\Axiom\Resolvers\DelegatingResolver;
use Superscript\Axiom\Sources\StaticSource;

// Create a filesystem instance (local filesystem example)
$adapter = new LocalFilesystemAdapter('/path/to/data');
$filesystem = new Filesystem($adapter);

// Set up the resolver with the filesystem
$resolver = new DelegatingResolver([
    LookupSource::class => LookupResolver::class,
]);
$resolver->instance(\League\Flysystem\FilesystemOperator::class, $filesystem);

// Define a lookup source
$lookup = new LookupSource(
    path: 'products.csv',
    filters: [new ValueFilter('category', new StaticSource('Electronics'))],
    columns: 'price'
);

// Wrap the source in an Expression and invoke it like a function
$query = new Expression($lookup, $resolver);
$result = $query(); // Result
```

Using Different Storage Backends
--------------------------------

[](#using-different-storage-backends)

The library uses [Flysystem](https://flysystem.thephpleague.com/) for filesystem abstraction, enabling you to read CSV files from various storage backends. The filesystem adapter is configured on the `LookupResolver`, allowing you to set the right filesystem adapter at runtime.

### Local Filesystem

[](#local-filesystem)

```
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use Superscript\Axiom\Expression;
use Superscript\Axiom\Lookup\{LookupResolver, LookupSource};
use Superscript\Axiom\Resolvers\DelegatingResolver;

$adapter = new LocalFilesystemAdapter('/path/to/data');
$filesystem = new Filesystem($adapter);

// Configure resolver with filesystem
$resolver = new DelegatingResolver([
    LookupSource::class => LookupResolver::class,
]);
$resolver->instance(\League\Flysystem\FilesystemOperator::class, $filesystem);

$lookup = new LookupSource(
    path: 'users.csv',
    filters: [new ValueFilter('status', new StaticSource('active'))],
    columns: ['name', 'email']
);

$result = (new Expression($lookup, $resolver))();
```

### Amazon S3

[](#amazon-s3)

```
use League\Flysystem\Filesystem;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
use Aws\S3\S3Client;
use Superscript\Axiom\Expression;
use Superscript\Axiom\Lookup\{LookupResolver, LookupSource};
use Superscript\Axiom\Resolvers\DelegatingResolver;

$client = new S3Client([
    'credentials' => [
        'key'    => 'your-key',
        'secret' => 'your-secret',
    ],
    'region' => 'us-east-1',
    'version' => 'latest',
]);

$adapter = new AwsS3V3Adapter($client, 'your-bucket-name');
$filesystem = new Filesystem($adapter);

// Configure resolver with S3 filesystem
$resolver = new DelegatingResolver([
    LookupSource::class => LookupResolver::class,
]);
$resolver->instance(\League\Flysystem\FilesystemOperator::class, $filesystem);

$lookup = new LookupSource(
    path: 'data/products.csv',
    filters: [new ValueFilter('category', new StaticSource('Books'))],
    columns: 'price'
);

$result = (new Expression($lookup, $resolver))();
```

### Reusing an Expression with Different Inputs

[](#reusing-an-expression-with-different-inputs)

`Expression` wraps a source together with the resolver and any named [`Definitions`](https://github.com/gosuperscript/axiom), and lets you invoke it like a function with per-call `bindings`. This is handy when the same lookup shape is reused with different symbol values:

```
use Superscript\Axiom\Expression;
use Superscript\Axiom\Resolvers\SymbolResolver;
use Superscript\Axiom\Sources\SymbolSource;

// Register SymbolResolver so `SymbolSource` placeholders can be resolved
$resolver = new DelegatingResolver([
    LookupSource::class => LookupResolver::class,
    SymbolSource::class => SymbolResolver::class,
]);
$resolver->instance(\League\Flysystem\FilesystemOperator::class, $filesystem);

// A lookup parameterised by a `category` symbol supplied at call time
$lookup = new LookupSource(
    path: 'products.csv',
    filters: [new ValueFilter('category', new SymbolSource('category'))],
    columns: 'price'
);

$query = new Expression($lookup, $resolver);

// Inspect required parameters derived from the source AST
$query->parameters(); // ['category']

// Invoke with bindings — equivalent forms
$electronics = $query(['category' => 'Electronics']);
$books       = $query->call(['category' => 'Books']);
```

### Other Storage Options

[](#other-storage-options)

Flysystem supports many adapters including:

- FTP/SFTP
- Azure Blob Storage
- Google Cloud Storage
- In-memory filesystem
- And many more...

See the [Flysystem documentation](https://flysystem.thephpleague.com/docs/) for more options.

Requirements
------------

[](#requirements)

- PHP 8.4+
- league/csv ^9.27.0
- league/flysystem ^3.0
- gosuperscript/monads

Documentation
-------------

[](#documentation)

For detailed documentation, examples, and API reference, see the main README.md file.

Testing
-------

[](#testing)

```
composer test          # Run all tests
composer test:unit     # Run unit tests
composer test:types    # Run static analysis
composer test:infection # Run mutation tests
```

Benchmarking
------------

[](#benchmarking)

```
composer bench              # Run all benchmarks
composer bench:aggregate    # Test aggregate functions
composer bench:memory       # Test memory efficiency
```

Performance Characteristics
---------------------------

[](#performance-characteristics)

- **Memory**: ~6.86MB constant usage regardless of file size
- **Early Exit**: First aggregate is 465x faster than full scan
- **Scalability**: Linear time scaling with row count
- **Validated**: Comprehensive benchmarks with files up to 100k rows

License
-------

[](#license)

Proprietary

Credits
-------

[](#credits)

Developed by GoSuperscript

Rebased on latest main
======================

[](#rebased-on-latest-main)

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance84

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

9

Last Release

81d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14931924?v=4)[Robert van Steen](/maintainers/robertvansteen)[@robertvansteen](https://github.com/robertvansteen)

---

Top Contributors

[![robertvansteen](https://avatars.githubusercontent.com/u/14931924?v=4)](https://github.com/robertvansteen "robertvansteen (14 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (10 commits)")[![fawazsuleiman](https://avatars.githubusercontent.com/u/129744165?v=4)](https://github.com/fawazsuleiman "fawazsuleiman (3 commits)")[![jcmvrij](https://avatars.githubusercontent.com/u/71216496?v=4)](https://github.com/jcmvrij "jcmvrij (2 commits)")

---

Tags

phpstreamingcsvtsvfilteringlookupaggregation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gosuperscript-schema-lookup/health.svg)

```
[![Health](https://phpackages.com/badges/gosuperscript-schema-lookup/health.svg)](https://phpackages.com/packages/gosuperscript-schema-lookup)
```

###  Alternatives

[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.2k70.2M244](/packages/openspout-openspout)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[concrete5/core

Concrete core subtree split

20166.1k52](/packages/concrete5-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
