- How do I install and set up Livewire CSV in my Laravel project?
- Run `composer require askdkc/livewire-csv` to install, then execute `php artisan livecsv-setup` to publish migrations and config. The command will prompt you to run migrations automatically or manually. Ensure Laravel queues are configured before proceeding.
- Does this package support large CSV files (e.g., 100K+ rows)?
- Yes, it uses Laravel queues and PHP generators to handle large files efficiently. However, performance depends on your queue workers, database indexing, and server resources. Test with production-scale data to validate.
- Can I use this package without Livewire in my Laravel app?
- No, this package is built specifically for Livewire and requires it to be installed. If your project doesn’t use Livewire, you’ll need to add it as a dependency, which may introduce additional complexity like Alpine.js for UI components.
- How do I integrate CSV imports into my User model?
- Add the `HasCsvImports` trait to your `User` model (or any other model) by including `use HasCsvImports;` at the top. The package will then enable CSV import functionality for that model via the Livewire component.
- What Laravel and Livewire versions does this package support?
- The package is actively maintained and works with recent Laravel (8.x+) and Livewire versions. Check the [changelog](https://github.com/askdkc/livewire-csv/blob/main/CHANGELOG.md) for specific version compatibility. Always test with your project’s exact versions.
- How does the package handle CSV parsing errors or malformed data?
- The package validates uploaded files and rows during import. Errors are typically logged or displayed via Livewire’s reactivity. You can customize error messages or retry logic by extending the provided components or traits.
- Are there any security risks with CSV uploads (e.g., injection attacks)?
- CSV injection risks (e.g., malicious formulas) aren’t explicitly mitigated, so validate all uploaded files. Adjust `file_upload_size` in your server config to prevent denial-of-service attacks from oversized files.
- Can I customize the import process (e.g., mapping columns, handling duplicates)?
- Yes, the package supports UPSERT operations for handling duplicates via database constraints. Customize column mappings or validation by overriding methods in the `HasCsvImports` trait or extending the Livewire component.
- What happens if my queue workers fail during a large import?
- Failed jobs are logged in Laravel’s `failed_jobs` table. Monitor queue failures using tools like Horizon or Supervisor. Ensure workers are running and configured with sufficient memory/concurrency to handle large imports.
- Are there alternatives to Livewire CSV for Laravel CSV imports?
- Alternatives include `maatwebsite/excel` (for Excel/CSV imports) or `spatie/laravel-import-exports` (for bulk operations). However, Livewire CSV is uniquely optimized for Livewire’s reactive UI and queue-based processing.