- Can I use this package directly in a Laravel project without Symfony?
- No, this is a Symfony bundle requiring Live Components. For Laravel, you’d need to either wrap Symfony’s ExporterService in a Laravel facade or deploy a Symfony microservice to handle exports via HTTP calls. The bundle’s #[AsLiveComponent] trait won’t work natively in Laravel.
- What Laravel versions does this package support?
- This package doesn’t support Laravel natively—it’s Symfony-only. However, you could integrate it with Laravel 8+ (PHP 8.0+) by abstracting Symfony’s components (e.g., Serializer, PhpSpreadsheet) into a Laravel service layer, assuming your Laravel app can tolerate Symfony’s dependencies.
- How do I handle Eloquent models if the bundle expects Doctrine?
- The bundle assumes Doctrine ORM, so Eloquent users must adapt the `getData()` method to return collections compatible with Symfony’s Serializer. Mock QueryBuilders or transform Eloquent results into Doctrine entities temporarily. Alternatively, build a custom data provider for the exporter.
- What’s the best way to avoid PhpSpreadsheet memory issues for large exports?
- Use PhpSpreadsheet’s streaming features (e.g., `setOutputEncoding`) or implement chunked exports by writing rows to disk incrementally. The bundle doesn’t natively support streaming, so you’d need to extend the `ExporterService` or pre-process data in batches before passing it to the exporter.
- Are there alternatives for Laravel that don’t require Symfony?
- Yes. For Laravel, consider `maatwebsite/excel` (Laravel-specific, Eloquent-friendly) or `spatie/laravel-excel` (built on Maatwebsite’s library). These avoid Symfony dependencies entirely and integrate seamlessly with Laravel’s ecosystem, including Livewire for reactive UX.
- How do I configure the export file path in Laravel?
- Since this bundle isn’t Laravel-native, you’d configure the path in Symfony’s `ux_export.yaml` (if using a microservice) or replicate the logic in a Laravel service. The default is `%kernel.project_dir%/var/export/`, but you’d map this to Laravel’s storage path (e.g., `storage/app/exports/`) via a custom adapter.
- Will this work with Laravel Livewire for reactive exports?
- Indirectly, but not natively. You’d need to build a Laravel Livewire component that calls a Symfony microservice or a Laravel-wrapped ExporterService. The bundle’s Live Component integration (e.g., `#[AsLiveComponent]`) won’t apply, so you’d handle reactivity in Livewire’s JavaScript layer.
- Can I customize export templates (e.g., branded XLSX files) beyond PhpSpreadsheet’s defaults?
- Yes, but you’d need to extend PhpSpreadsheet’s `Spreadsheet` class or override the bundle’s `ExporterService`. The bundle doesn’t provide built-in theming, so you’d inject custom styles or layouts via the `setActiveSheetIndex()` or `getActiveSheet()` methods after export generation.
- How do I handle many-to-many relationships in exports?
- Use the `manyToMany` option in `#[ExportableProperty]` with `MODE_SHEET` to create a separate worksheet or `MODE_LINES` to duplicate rows. For complex relations, pre-process the data in your controller/service to flatten or denormalize the structure before passing it to the exporter.
- What’s the impact on CI/CD if I add this bundle to a Laravel project?
- Adding Symfony dependencies (e.g., `symfony/ux-live-component`, `phpoffice/phpspreadsheet`) may require CI updates for PHP version constraints or dependency conflicts. Test your pipeline with `composer validate` and ensure your Laravel stack (e.g., PHPUnit, Pest) remains compatible with Symfony’s autoloading.