Download the PHP package real-media-technic-staudacher/laravel-flatfiles without Composer

On this page you can find all versions of the php package real-media-technic-staudacher/laravel-flatfiles. 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 laravel-flatfiles

Export Eloquent queries to flatfiles using simple configuration

[]() TravisCI

Installation

composer require real-media-technic-staudacher/laravel-flatfiles:^5.0

To overwrite the default configuration

php artisan vendor:publish

Then select the option Provider: RealMediaTechnicStaudacher\LaravelFlatfiles\FlatfileExportServiceProvider. The default configuration looks like:

As you see, right now, only CSV exports are supported ;-)

Usage example / Basic workflow

Load export

Easiest way is to auto-inject the FlatfileExport while implementing the FlatfileFields interface:

If you want to use a dedicated class for field definitions are get the array from somewhere else use withFields()

Specify target file / location

Using filesystem disk

Prepare global export resources

...

Loop through data and write to export file

Finish export

$flatfile->moveToTarget();

Define fields

Fields are defined within an object/class implementing the FlatfileFields interface, thus a public function field(). Implement this function directly in your export-handling class, or in a dedicated sort like a DTO class.

Why? You get the possiblity to add callbacks in your field definitions, so that you can define dynamic cells easily

In your field() method you need to define an array of fields. This will generate a flatfile with one column each field array element.

Assume we load a collection of products having attributes named product_name. The definition looks like:

The field defintions are pretty flexible. Better learn by examples by yourself

One row for each relation

If you have a relation you want to put into one row and preserve it's parent as one row if it hasn't a relation, you can use the following:

SYLK file format error

By default, an exception getting thrown if the first column in the header row is named ID. Background for this is the SYLK formatting, which does not allow an flawless opening with Microsoft Excel in some Versions. You are free to disable the exception via the config drivers.csv.ignore_sylk_exception again.

Upgrade guide

To v3 from v2


All versions of laravel-flatfiles with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
laravel/framework Version ^9.0|^10.0
league/csv Version ^9.8
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 real-media-technic-staudacher/laravel-flatfiles contains the following files

Loading the files please wait ....