This is library with the objective of exporting information from the database in a simple way.

Overview

Symfony Entity Exporter

License: MIT

Goldbach Algorithms Symfony Entity Exporter (fondly nicknamed Entity Exporter) is a library developed for the Symfony framework with the objective of exporting information from the database in a simple way.

Compatible output extensions: CSV, XLS and PDF

Installation

Use the composer to install

composer require goldbach-algorithms/symfony-entity-exporter

Configuration

Make the settings below according to your project's needs within your .env file

ENTITY_PATH

If you have changed the paron directory for entities in your project, you must set the ENTITY_PATH variable within your .env file to indicate the new directory.

TRANSITORY_MEMORY

As an option it is also possible to define within the .env file of your project a value for the variable TRANSITORY_MEMORY, which will change the php memory limit during the execution of the export to avoid crashes. The default value is 1GB.

Usage

See some examples of using Symfony Entity Exporter

See the .csv export example

use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Set $data (query return) and entity class
$response = $entityExporter->csv(
            $data,
            User::class,
            UserDataExport::class, # Data Export Template (not required)
            'Title', # Title (not required)
            'Filename', # File .csv name (not required)
            ';' # .csv Delimiter (not required) default ;
        );

# Exporting file (.csv)
return $response;

You can also generate a .pdf file from the entity query return.

See the .pdf export example

use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Set $data (query return) and entity class
$response = $entityExporter->pdf(
            $data,
            User::class,
            UserDataExport::class, # Data Export Template (not required)
            'Filename', # File .pdf name (not required),
            'Header content', # (not required)
            'Footer content', # (not required)
            'P', # Portrait or Landscape (not required)
            '10', # Margin Header (not required)
            '10', # Margin Footer (not required)
            '10', # Top content margin (not required)
            'A4', # Print Format (not required)
            'utf-8', # Char Mode (not required)
        );

# Exporting file (.pdf)
return $response;

And you can also export an html template, for example a twig file

See the .pdf by html export example

use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Set a content
$content = $this->renderView('content.html.twig', $vars);

# Call the method pdfByHtml()
$response = $entityExporter->pdfByHtml(
            $content,
            'Filename', # File .pdf name (not required),
            'Header content', # (not required)
            'Footer content', # (not required)
            'P', # Portrait or Landscape (not required)
            '10', # Margin Header (not required)
            '10', # Margin Footer (not required)
            '10', # Top content margin (not required)
            'A4', # Print Format (not required)
            'utf-8', # Char Mode (not required)
        );

# Exporting file (.pdf)
return $response;

You can create an export template following the example in src/ExampleDataExport.php by adding a App\DataExport directory to your application.

EasyAdminBundle

The Entity Exporter is compatible with the Easy Admin Bundle, so it is possible to use a request within a Controller on the page and perform data export.

See the .xls export example

use EasyCorp\Bundle\EasyAdminBundle\Factory\AdminContextFactory;
use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Inject the AdminContextFactory and define public

/** @var AdminContextFactory  */
public $adminContextFactory;

public function __construct(AdminContextFactory $adminContextFactory)
{
   $this->adminContextFactory = $adminContextFactory;
}

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Get the FilterFactory into Controller
$filterFactory = $this->get(FilterFactory::class);

# Use the Entity Exporter builder to EasyAdmin
$data = $entityExporter->getEasyAdminQuery(
            $request,
            $filterFactory,
            $this,
            [
                'id' => 1
            ]
        );

# Set $data (query return) and entity class
$response = $entityExporter->xls($data, User::class);

# File .xls
return $response;

License

MIT

Copyright © 2021 Goldbach Algorithms

You might also like...
Simple wrapper package around MPDF's setProtection method that allows you to set password on PDF files

Laravel PDF Protect (fork) Simple wrapper package around MPDF's setProtection method that allows you to set password on PDF files. Installation You ca

Dompdf - Simple Dompdf package for Laravel

Dompdf - Simple Dompdf package for Laravel

YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Validate your input data in a simple way, an easy way and right way. no framework required. For simple or large. project.

wepesi_validation this module will help to do your own input validation from http request POST or GET. INTEGRATION The integration is the simple thing

The objective of this Project is to generate Stock Management
The objective of this Project is to generate Stock Management

Stock-Management The objective of this Project is to generate Stock Management Items / purchases, Sales Stock Client Provider Sales Management Purchas

The objective of this project is to manage The Website Manga, this site permits to Client to show, read and download Manga with the possibility to react, vote, and save his data.
The objective of this project is to manage The Website Manga, this site permits to Client to show, read and download Manga with the possibility to react, vote, and save his data.

The objective of this project is to manage The Website Manga, this site permits to Client to show, read and download Manga with the possibility to react, vote, and save his data.

Perch Dashboard app for exporting content to (Kirby) text files and Kirby Blueprint files
Perch Dashboard app for exporting content to (Kirby) text files and Kirby Blueprint files

toKirby Perch Dashboard app for exporting content to (Kirby) text files and Kirby Blueprint files. You can easily install and test it in a few steps.

The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)

gRPC - An RPC library and framework gRPC is a modern, open source, high-performance remote procedure call (RPC) framework that can run anywhere. gRPC

The objective of ParaTest is to support parallel testing in PHPUnit

The objective of ParaTest is to support parallel testing in PHPUnit. Provided you have well-written PHPUnit tests, you can drop paratest in your project and start using it with no additional bootstrap or configurations!

The VarExporter component allows exporting any serializable PHP data structure to plain PHP code.

The VarExporter component allows exporting any serializable PHP data structure to plain PHP code. While doing so, it preserves all the semantics associated with the serialization mechanism of PHP (__wakeup, __sleep, Serializable).

Data Table package with server-side processing, unlimited exporting and VueJS components
Data Table package with server-side processing, unlimited exporting and VueJS components

Data Table package with server-side processing, unlimited exporting and VueJS components. Quickly build any complex table based on a JSON template.

Magento n98-magerun module for importing and exporting configuration data
Magento n98-magerun module for importing and exporting configuration data

Magento n98-magerun module for importing and exporting configuration data. Import supports hierarchical folder structure and of course different environments.

CRUD  Build a system to insert student name information, grade the class name, and edit and delete this information
CRUD Build a system to insert student name information, grade the class name, and edit and delete this information

CRUD Build a system to insert student name information, grade the class name, and edit and delete this information

MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

Dump masked information from your database

Laravel Masked DB Dump A database dumping package that allows you to replace and mask columns while dumping your database. Installation You can instal

A Full Stack login/register system using a MySQL database to store the information
A Full Stack login/register system using a MySQL database to store the information

This is a Full Stack login/register system using a MySQL database to store the information. I created this to sharpen my Full Stack Development skills.

A web application built on PHP for user to view their credit information in their mysql database
A web application built on PHP for user to view their credit information in their mysql database

TheCreditInfo Table of Content About Inspiration Technologies Client Pages Usage About Credere is a website created to help you track your credit hist

Library JGU is a website created for a university library system information. Made with PHP & TailwindCSS.
Library JGU is a website created for a university library system information. Made with PHP & TailwindCSS.

Library JGU Library JGU is a website created for a university library system information. Made with PHP & TailwindCSS. Key Features • How To Use • Rel

Comments
  • Can't configure Transitory Memory

    Can't configure Transitory Memory

    At first the bundle didn't work for me (the screen went blank); only exporting files at seemingly random times. Through logs I determined it was a memory issue ('not enough bytes allocated'), and so, I wrote in my .env the "TRANSITORY_MEMORY" variable; but for some reason it didn't recognized it ("Function name must be a string").

    After looking through the files, I discovered an error in the "SymfonyEntityExporterAdmin">"transitoryMemory" function, originally...:

    public function transitoryMemory() { $transitoryMemory = self::DEFAULT_TRANSITORY_MEMORY; if (isset($_ENV[self::TRANSITORY_MEMORY]) && !empty($_ENV[self::TRANSITORY_MEMORY])) { $transitoryMemory = $_ENV(self::TRANSITORY_MEMORY); } ini_set('memory_limit', $transitoryMemory); }

    ...the brackets of the line inside the if are not the right ones. The line...:

    $transitoryMemory = $_ENV(self::TRANSITORY_MEMORY);

    ...worked when changed to...

    $transitoryMemory = $_ENV[self::TRANSITORY_MEMORY];

    That only works on local, though.

    opened by JoseM166 1
Releases(1.3.1)
Owner
Goldbach Algorithms
Powered by Gustavo Alves
Goldbach Algorithms
PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage

Snappy Snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopd

KNP Labs 4.1k Dec 30, 2022
Official clone of PHP library to generate PDF documents and barcodes

TCPDF PHP PDF Library Please consider supporting this project by making a donation via PayPal category Library author Nicola Asuni [email protected] co

Tecnick.com LTD 3.6k Jan 6, 2023
TCPDF - PHP PDF Library - https://tcpdf.org

tc-lib-pdf PHP PDF Library UNDER DEVELOPMENT (NOT READY) UPDATE: CURRENTLY ALL THE DEPENDENCY LIBRARIES ARE ALMOST COMPLETE BUT THE CORE LIBRARY STILL

Tecnick.com LTD 1.3k Dec 30, 2022
Pdf and graphic files generator library written in php

Information Examples Sample documents are in the "examples" directory. "index.php" file is the web interface to browse examples, "cli.php" is a consol

Piotr Śliwa 335 Nov 26, 2022
PdfParser, a standalone PHP library, provides various tools to extract data from a PDF file.

PdfParser Pdf Parser, a standalone PHP library, provides various tools to extract data from a PDF file. Website : https://www.pdfparser.org Test the A

Sebastien MALOT 1.9k Jan 2, 2023
PHP library allowing PDF generation or snapshot from an URL or an HTML page. Wrapper for Kozea/WeasyPrint

PhpWeasyPrint PhpWeasyPrint is a PHP library allowing PDF generation from an URL or an HTML page. It's a wrapper for WeasyPrint, a smart solution help

Pontedilana 23 Oct 28, 2022
Official clone of PHP library to generate PDF documents and barcodes

TCPDF PHP PDF Library Please consider supporting this project by making a donation via PayPal category Library author Nicola Asuni [email protected] co

Tecnick.com LTD 3.6k Dec 26, 2022
PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page.

Snappy Snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopd

KNP Labs 4.1k Dec 30, 2022
Generate simple PDF invoices with PHP

InvoiScript Generate simple PDF invoices with PHP. Installation Run: composer require mzur/invoiscript Usage Example use Mzur\InvoiScript\Invoice; re

Martin Zurowietz 16 Aug 24, 2022
Rapidly Generate Simple Pdf, CSV, & Excel Report Package on Laravel

Laravel Report Generators (PDF, CSV & Excel) Rapidly Generate Simple Pdf Report on Laravel (Using barryvdh/laravel-dompdf or barryvdh/laravel-snappy)

Jimmy Setiawan 513 Dec 31, 2022