- How do I install lephare/import in a Laravel application?
- Install it with Composer using composer require lephare/import, then publish any package configuration with php artisan vendor:publish and confirm the service provider is registered (or auto-discovered). After that you define an import class that describes the file source and field mapping, and run it against a CSV or XLS file. Pin an exact version and commit your composer.lock before rolling it into anything beyond a proof of concept.
- Does lephare/import support both CSV and XLS/XLSX files?
- The package is described as handling structured imports for both CSV and Excel-style files. Be aware that spreadsheet support typically pulls in a heavyweight dependency such as phpoffice/phpspreadsheet, which loads more of the workbook into memory than a streaming CSV reader would. Check composer.json to see exactly which parser is used and how that affects your memory budget for large files.
- How does field mapping work when importing into Eloquent models?
- The package supports configurable field mapping, so you declare which file column feeds which model attribute rather than relying on hard-coded positions. That mapping layer is where you should also normalize headers, encodings, and date formats before values reach Eloquent. Keep business-specific mapping rules in your own importer class so they survive a package upgrade or swap.
- Can lephare/import handle large files without running out of memory?
- The package advertises chunked processing, which is the right mechanism for keeping memory flat on big imports. The important detail is whether CSV is streamed row by row or buffered whole, and whether XLS workbooks are read in a memory-efficient mode. Benchmark a representative large file in your target environment, including memory_limit and max_execution_time, before committing to the package.
- Can imports be run as queued background jobs in Laravel?
- There is no field evidence that the package assumes synchronous request-context execution, but you should verify it is stateless enough to be called from a queued job. A safe pattern is to wrap the import behind your own App\Contracts\FileImporter interface and dispatch it from a job, chunking rows so each job stays within queue timeouts. That approach also gives you progress tracking and retry semantics that the package alone may not provide.
- How are validation errors handled per row during an import?
- The package supports validation, but you should confirm whether it collects errors per row and continues, or fails fast on the first invalid record. For bulk admin imports, per-row error collection is usually preferable because it lets users fix a handful of rows and re-upload. If the package only fails fast, wrap it with your own validator that accumulates failures into an error report.
- Which Laravel and PHP versions does lephare/import support?
- Inspect composer.json for the exact illuminate/* and php constraints, because narrow Laravel version ranges are a common upgrade blocker. The package targets modern Laravel with PHP 8.x, but the definitive answer is in the dependency constraints and the tags themselves. Test against every PHP and Laravel version in your production matrix rather than assuming a single passing install is sufficient.
- Is lephare/import actively maintained and safe to use in production?
- This is a small, agency-maintained package with very few stars and no known downstream dependents, so bus factor is the main risk rather than code quality. One release also carries a future-dated timestamp, which suggests a mirror artifact or re-tagged history worth verifying against the actual Git tag and CHANGELOG. Treat adoption as a greenfield POC, wrap the package behind an application-level interface, and pin exact versions so an abandoned release cannot break your upgrades.
- How does lephare/import compare to Laravel Excel or league/csv?
- Maatwebsite's Laravel Excel is the better-known, more heavily used option for spreadsheet imports with export support, while league/csv is a lightweight streaming reader if you only need CSV. lephare/import sits in the middle as a small file-to-model convenience layer with mapping, validation, and chunking built in. If you need broad community support and documentation, the established alternatives carry less integration risk; if you want something minimal to wrap behind your own importer contract, this is a reasonable candidate.
- What are common pitfalls when importing CSV or Excel files with a Laravel package?
- The usual sources of import bugs are hidden assumptions about header rows, character encoding such as UTF-8 BOM or ISO-8859-1, and locale-specific date and number parsing. Transactional integrity and idempotency on re-runs are also frequently missing, so a failed import can leave partial data behind. Normalize input in your own importer layer and add a deduplication key before trusting any package to write directly to your models.