A utlity Symfony bundle to help with export data from Symfony applications.
It allows exports by default in the formats csv
and xlsx
. With the ability to add support for more formats via custom Exporters.
This bundle allows you to export data via 3 methods: Direct Download, Background Download, Background Email. More info here
To add to your project
composer require parthenon/export-bundle
- PHP 8.1+
- Symfony 6+
Support is provided via GitHub, Slack, and Email.
If you have a commercial license you will be able to list the GitHub accounts that you want to link to the license. This means when an issue is created by an account linked to a commercial license they will get priority support. All other issues will be given best effort support.
- Github: You can make an issue on getparthenon/monorepo
- Email: [email protected]
- Slack: Click here to signup
Issues we will provide support and fixes for:
- Defects/Bugs
- Performance issues
- Documentation fixes/improvements
- Lack of flexibility
- Feature requests
namespace App\Controller;
use App\Export\DemoDataProvider;
use Parthenon\Export\Engine\EngineInterface;
use Parthenon\Export\Exporter\ExporterManagerInterface;
use Parthenon\Export\Exporter\ExporterManagerInterface;
use Parthenon\Export\Response\ResponseConverterInterface;
use Parthenon\Export\Entity\BackgroundExportRequest;
use Parthenon\Export\Repository\BackgroundExportRequestRepositoryInterface;
class ExportController
{
public function export(Request $request, EngineInterface $engine, ResponseConverterInterface $responseConverter)
{
$exportName = $request->get("name");
$exportFormat = $request->get("format");
$exportRequest = new ExportRequest($exportName, $exportFormat, DemoDataProvider::class, $parameters);
$response = $engine->process($exportRequest);
return $responseConverter->convert($response);
}
public function downloadWaiting(Request $request, LoggerInterface $logger, BackgroundExportRequestRepositoryInterface $backgroundExportRequestRepository, Environment $twig)
{
$id = $request->get('id');
/** @var BackgroundExportRequest $backgroundExportRequest */
$backgroundExportRequest = $backgroundExportRequestRepository->findById($id);
$downloadUrl = $backgroundExportRequest->getExportedFilePath();
if ($downloadUrl) {
return new RedirectResponse($downloadUrl);
} else {
return new Response($twig->render('export_background_download.html.twig'));
}
}
}
<?php
namespace App\Export;
use Parthenon\Export\DataProvider\DataProviderInterface;
class DemoDataProvider extends DataProviderInterface
{
public function __construct(
private DemoDataRepositoryInterface $repository,
) {
}
public function getData(ExportRequest $exportRequest): iterable
{
return $this->repository->findAll();
}
}
You can find the full documentation in Parthenon Docs for Export
This is where the export is generated within the HTTP request and a download file is provided.
This is where the export is generated within the background via Symfony Messenger and once the download is generated it's saved to a storage area and then the user can download it.
The file uploading part of the background download engine is handled by the common module of Parthenon. The full documentation can be found here.
If you want to save the file to a local folder the configuration below can help.
parthenon:
common:
uploader:
default:
provider: local
naming_strategy: time_random
local:
path: "%kernel.project_dir%/public/uploads"
This is where the export is generated within the background via Symfony Messenger. Once the export is generated it's emailed to the requesting user.
The email sending part of this engine is handled by the Notification module of Parthenon. The full documentation can be found at here
If you're already using Symfony Mailer and just want that to be used then the configuration below is what is needed.
parthenon:
notification:
type: symfony
Yes. This bundle has been released under the GPL V3 License.
This has been released under an open source license for two reasons. One is that data exports is a source of technical debt for many tech teams and I wanted this to be useful to as many people as possible as I feel it really helps solve the issue for many teams.
The other reason is to see the usage and bug reports, etc from an open source version.
No. As the copyright holder the GPL license doesn't apply to me and I'm legally entitled to distribute it how I want, relicense it, etc. GPL only affects people who fork this bundle.
This bundle comes with community level support, which is best efforts. You can get a professional support by paying for a Parthenon license. Which is $250 per developer per year.