- How do I install rodenastyle/stream-parser in a Laravel app?
- Install it with Composer using composer require rodenastyle/stream-parser. The package follows Laravel conventions with a service provider and facade, so auto-discovery should register it without custom bootstrapping. No database migrations or config publishing are required. After installation, verify the package's Composer constraints against your app's PHP and Laravel versions.
- Which Laravel and PHP versions does rodenastyle/stream-parser support?
- The package is described as PHP7 and Laravel-oriented, with a dependency on illuminate/support for framework integration. The exact supported Laravel majors and PHP versions are defined by the current release's composer.json constraints. Do not assume compatibility from the README alone; check the constraints against your app's Laravel major and upgrade horizon.
- What file formats can stream-parser parse?
- It supports CSV, XML, JSON, and pipe or TXT-style delimited files. Parsing is designed for row-at-a-time consumption rather than loading the entire file into memory. The XML path relies on PHP's streaming ext-xmlreader extension, so confirm that extension is available in your local, CI, and container runtimes.
- Does stream-parser keep memory usage flat for very large files?
- Yes, the package is built around PHP generators and processes files row by row, so memory stays flat relative to file size. That is the main reason to use it instead of file_get_contents combined with json_decode or DOM-based parsing. However, your own callbacks must not accumulate rows into arrays, because that would negate the streaming benefit.
- How do I parse a large CSV file with StreamParser in Laravel?
- The fluent facade generally looks like StreamParser::csv()->parse($path)->each(function ($row) { ... }). Process each row inside the callback and avoid collecting all rows into memory. Persist or batch records incrementally as you go. The same streaming approach applies to the package's other supported formats.
- What happens when stream-parser encounters malformed CSV or invalid JSON?
- The package's behavior on malformed input is not something you should assume; it may throw, skip, coerce, or partially parse depending on the format. Streaming parsers often tolerate ragged rows, encoding anomalies, and malformed records differently from strict parsers. Test malformed input explicitly for each format you use and add your own validation and error surfacing. Also check whether line numbers or offsets are exposed in errors.
- Can stream-parser read files from Laravel Storage, S3, or non-local streams?
- The package is intentionally minimal, and its fluent API is typically used with a local file path. Support for Flysystem disks, remote streams, SplFileObject, or temp files from S3 downloads should be verified rather than assumed. A safe pattern is to download remote files to a local temporary path before parsing. If you need a raw iterator or stream abstraction, check whether the package exposes an escape hatch.
- Is stream-parser a complete Laravel import solution with validation and batching?
- No. It is a parser, not an importer. Validation, type coercion, persistence, batching, checkpointing, and dead-lettering all remain your responsibility. The best architectural fit is behind a port or adapter boundary, such as an ImportParser interface, so controllers and callbacks do not couple directly to the package. Treat it as a commodity utility rather than an end-to-end ingest platform.
- How should I handle failures mid-stream when using stream-parser?
- If a generator throws on row N, rows 1 through N-1 may already have been processed or written. Without your own transaction or checkpoint strategy, retries can duplicate rows or leave partial imports. Design idempotent writes, checkpoints, or transactional batching around the parser. This is an integration-design concern rather than a defect in the package itself.
- Is rodenastyle/stream-parser actively maintained and safe for production use?
- It is effectively a single-maintainer project at roughly 440 stars, with a recent release date of 2025-05-13. The small codebase makes bus-factor risk cheap to mitigate by forking, vendoring, or replacing it if needed. Pin the version, test malformed input and production failure semantics explicitly, and monitor for correctness or security issues. For large-file ETL and imports, it is a reasonable low-risk utility when wrapped behind your own interface.