gosuperscript/schema-lookup
Composer 安装命令:
composer require gosuperscript/schema-lookup
包简介
A PHP library for querying CSV/TSV files with streaming, dynamic filtering, aggregate functions, and range-based banding.
README 文档
README
A high-performance PHP library for querying CSV/TSV files with streaming, dynamic filtering, aggregate functions, and range-based banding.
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:
ValueFilterandRangeFilterfor 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:
firstaggregate 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
composer require gosuperscript/axiom-lookup
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<Option<mixed>>
Using Different Storage Backends
The library uses Flysystem 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
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
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
Expression wraps a source together with the resolver and any named
Definitions, 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
Flysystem supports many adapters including:
- FTP/SFTP
- Azure Blob Storage
- Google Cloud Storage
- In-memory filesystem
- And many more...
See the Flysystem documentation for more options.
Requirements
- PHP 8.4+
- league/csv ^9.27.0
- league/flysystem ^3.0
- gosuperscript/monads
Documentation
For detailed documentation, examples, and API reference, see the main README.md file.
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
composer bench # Run all benchmarks composer bench:aggregate # Test aggregate functions composer bench:memory # Test memory efficiency
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
Proprietary
Credits
Developed by GoSuperscript
Rebased on latest main
gosuperscript/schema-lookup 适用场景与选型建议
gosuperscript/schema-lookup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 117 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「csv」 「streaming」 「tsv」 「aggregation」 「filtering」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gosuperscript/schema-lookup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gosuperscript/schema-lookup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gosuperscript/schema-lookup 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A laravel bundle for the OpenTok PHP SDK
Laravel Wrapper for the OpenTok PHP SDK
A robust, configuration-driven ETL and data import framework for Laravel. Handles CSV/Excel streaming, queues, validation, and relationships.
laravel facade to read/write csv file
Collection of tools to use the full power of the Enyalius framework
Web UI + API to execute Symfony console commands from the browser or any AI agent. Auto-discovers commands, dynamic forms, NDJSON streaming terminal.
统计信息
- 总下载量: 117
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-01-12