Download the PHP package santwer/exporter without Composer

On this page you can find all versions of the php package santwer/exporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package exporter

Word Template Exporter

Package for easy Word exports in Laravel on given Templates. This package is based on phpoffice/phpword.

Commit Activity Total Downloads Latest Stable Version License

Table of Contents

Installation

Exporter is installed via Composer. To add a dependency to Exporter in your project, either

Run the following to use the latest stable version

or if you want the latest master version

You can of course also manually edit your composer.json file

Configuration (optional)

To use pdf export it is needed to install LibreOffice. WordTemplateExporter is using the soffice command to convert the docx file to pdf.

Windows

Download and install LibreOffice from here Also add the path to the soffice command to the system environment variables.

How to use with ExportClasses

Usage

You can use the WordExporter Facade as follows. The format of the exported file is determined by the file extension. Supported formats are .docx and .pdf.

Creating a New Export

You can create a new export using the following Artisan command:

Replace {className} with the name of the new export class.

Interfaces

The object $export can be implemented with the following interfaces:

Interface Description Example
FromWordTemplate Required. Interface indicating the export is from a Word template. class MyExportClass implements FromWordTemplate
GlobalTokens Interface for providing global tokens for replacement in Word template. class MyGlobalTokens implements GlobalTokens
TokensFromArray Interface for providing tokens from an array for replacement in Word template. class MyArrayTokens implements TokensFromArray
TokensFromCollection Interface for providing tokens from a collection for replacement in Word template. class MyCollectionTokens implements TokensFromCollection
TokensArray Interface for providing tokens from an array without any block data
TokensFromObject Interface for providing tokens from an object/class without any block data
TokensFromModel Interface for prodiding tokens from a model without any block data
WithCharts Interface that allows you to replace text charts as array
WithCheckboxes Interfaces that allows you to replace text with Checkboxes, either checked or not checked
WithImages Interface that allows you to replace text with Images

Each of these interfaces defines methods that need to be implemented according to the specific requirements of the export process. These methods typically involve returning an array of key-value pairs where keys represent placeholders in the Word template and values are the data to replace those placeholders with.

Example

Word file:

Controller:

Export Class:

Charts

To replace a chart in a Word template, you can use the WithCharts interface. This interface requires the implementation of the charts method, which should return an array of key-value pairs where keys represent placeholders in the Word template and values are the data to replace those placeholders with. You can find all infos about the charts here

Possible types are 'pie', 'doughnut', 'line', 'bar', 'stacked_bar', 'percent_stacked_bar', 'column', 'stacked_column', 'percent_stacked_column', 'area', 'radar', 'scatter'

Images

To replace an image in a Word template, you can use the WithImages interface. This interface requires the implementation of the images method, which should return an array of key-value pairs where keys represent placeholders in the Word template and values are the data to replace those placeholders with.

For more Details how to set Images you can find here

Tables

To replace a table in a Word template, you can use the WithTables interface. This interface requires the implementation of the tables method, which should return an array of key-value pairs where keys represent placeholders in the Word template and values are the data to replace those placeholders with.

Note: For export in pdf at least the headers need the width of the columns. Not settet column widths might not be shown.

How to use in Query

Add Trait Exportable

As default all Variables are available of the Model. Add a Concern for special export fields.

You can add a fixed Template for each Model.

You can also define own Blocknames for the use of the Model in a template.

Basic Export

export() gives download response back.

If you defined export template in Model.

It's also possible to set Export-Command after Executing the query or on a Model after Find-Command

Export as PDF

Generally with the option format = pdf it is possible to export pdf. It is important that libreOffice is installed for that actions.

For short terms it is possible to call Export functions as PDF

Autoloading Relations

Before exporting, the Package is checking for defined Relations. If there is no related Variable it will automatically remove unneeded relations. This behavior can be changed within the config. For that it is needed to set up a config File exporter.php in config/

Also is the Package checking for relations that are not loaded yet. It will automatically load the Relations before exporting. Therefore, it is possible to reduce the Export-Code from

to

If the Relation is already loaded it will not be affected.

Variables

It is possible to set up variables which are not affected by the Model or Query.

Template Variables/Blocks

In the template the package always looks for loops/Blocks (except for Global Variables). By Default the Blockname is the name of the table. It is also possible to use an own name for that.

To export Customers with Name and e-mail addresses, it is needed to add the Block.

If there is a Relation within the customer.

If there is a Relation with a collection of Entries.

For each Relation it will add up its relation block name.

Relation Variable with Condition

It is possible to define Variables which are Related to many Entries. Therefore, you can reduce it to one relation and get a certain Value in the relation.

It will only select one entry.

However, you can set up one where condition to get the entry.

If the Entry is not found the Values of the Model will be null.

Template

The Template should be DOCX or DOC. The File will be cloned and saved in the sys_temp_folder as long it has no store option. For PDF exports it is needed to use LibreOffice. Therefore, the soffice command needs to be executable.

For the Templateprocessing it uses phpoffice/phpword More Infos you can find here


All versions of exporter with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ^8.0|^9.0|^10|^11
php Version ^7.4|^8.0|^8.2|^8.2
phpoffice/phpword Version ^v1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package santwer/exporter contains the following files

Loading the files please wait ....