Download the PHP package nalabdou/algebra-csv without Composer
On this page you can find all versions of the php package nalabdou/algebra-csv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nalabdou/algebra-csv
More information about nalabdou/algebra-csv
Files in nalabdou/algebra-csv
Package algebra-csv
Short Description CSV adapter for algebra-php — file paths, SplFileInfo, raw strings, resource handles. Auto-detect delimiter, encoding conversion, type coercion.
License MIT
Informations about the package algebra-csv
algebra-csv
CSV adapter for algebra-php.
Accepts file paths, SplFileInfo, raw CSV strings, and resource handles.
Auto-detects delimiter. Encoding conversion. Type coercion.
Installation
Requirements: PHP ≥ 8.2, ext-mbstring
Quick start
Register adapters once at bootstrap, then use Algebra::from() anywhere.
File path
Raw CSV string
Resource handle
Bootstrap — register all adapters at once
A single setup call at application entry point covers all three input types:
After that, Algebra::from() accepts file paths, SplFileInfo, CsvString, and resource handles with no further configuration.
Named constructors (::from())
Every adapter exposes a ::from(CsvOptions) static named constructor:
CsvString follows the same pattern:
Supported inputs
| Input | Adapter | Notes |
|---|---|---|
string (file path) |
CsvFileAdapter |
Must exist and be readable |
SplFileInfo / SplFileObject |
CsvFileAdapter |
Symfony's File works too |
CsvString |
CsvStringAdapter |
Wraps raw CSV content |
resource (stream) |
CsvResourceAdapter |
Caller owns fclose() |
Configuration
All adapters accept a CsvOptions instance:
Fluent builder
Auto-delimiter detection
When delimiter is null (the default), DelimiterDetector samples the first 4 KB and picks the most consistently-occurring character from [',', ';', "\t", '|']:
Encoding conversion
Pass the source encoding — the parser converts everything to UTF-8 automatically:
Type coercion
With coerceTypes: true, numeric strings are cast to int or float:
Interfaces
The src/Contract/ directory exposes stable interfaces for DI and extension:
| Interface | Purpose |
|---|---|
CsvAdapterInterface |
All adapters; adds ::from() and getOptions() on top of AdapterInterface |
CsvParserInterface |
Low-level parser — swap in a custom implementation via constructor injection |
DelimiterDetectorInterface |
Detector — swap in a custom strategy |
With algebra-symfony
Registered automatically — no services.yaml needed. Use Algebra::from() directly throughout the application.
Requirements
| Version | |
|---|---|
| PHP | ≥ 8.2 |
| ext-mbstring | * |
| nalabdou/algebra-php | ^1.0 |
Contributing
See CONTRIBUTING.md for development setup, coding standards, and how to add adapters or parser features.
License
MIT — see LICENSE.