Download the PHP package akosnoavek/models-data-extractor without Composer

On this page you can find all versions of the php package akosnoavek/models-data-extractor. 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 models-data-extractor

Laravel Models Data Extractor

Extract information from Eloquent models, plain PHP arrays, or generic objects, based on a declarative schema, and render the result as an IteratorElement tree, a plain array, JSON, HTML, CSV, or XLSX.

Installation

The package ships a Laravel service provider (AkosNoavek\DataExtractor\Support\ServiceProvider) and a DataExtractor facade, both auto-discoverable via the laravel.providers / laravel.aliases entries in composer.json.

Configuration

Publish the config file to customize it:

This creates config/data_extractor.php:

Core concepts

Every extraction involves two independent things:

  1. The target — the data you are extracting from. It can be an Eloquent Model, a plain PHP array, or a generic object (e.g. the result of json_decode).
  2. The schema — a declarative description of what to extract and how to label it: which fields to pull out, how to group them into sections, and how to format them.

DataExtractor::make($target) binds the target; the terminal method (toArray, toJson, toHtml, toCsv, toXlsx, extract) binds the schema and runs the extraction.

The schema data structure

A schema is a nested associative array (or its JSON equivalent) built from two kinds of nodes: fields and sections.

Field

A leaf node that reads a single value out of the target.

Section

A node that groups other fields/sections together under a label.

Sections can be nested arbitrarily deep — a section's fields array can itself contain other sections.

Internally, every node (field or section) is parsed into an AkosNoavek\DataExtractor\Iterators\IteratorElement. The keys of the fields array are only used as PHP array keys while you author the schema; they are not part of the output. If a child node doesn't declare its own label, its schema key is used as the label.

Root sections (relations / collections)

A section can pull its target from a relation or nested collection on the parent target, instead of the outer target, via root:

A resolved Eloquent model is only recognized as a "single related model" if its base class is Illuminate\Database\Eloquent\Model or is registered via data_extractor.model_classes — otherwise it is (mis-)treated as an empty collection and the whole section silently disappears from the output. If your models extend a shared base class, make sure to register it.

Multi-value fields (.*. path syntax)

A single field can also flatten a to-many relation into one value, without declaring a nested section, using .*. in its path:

This resolves name on every item of the children relation/collection and joins them into one string, using the separator configured for the output format (toHtml/toCsv/toXlsx/toArray use "<br>").

Providing the schema: inline array vs. JSON file

Every terminal method (extract, toArray, toJson, toHtml, toCsv, toXlsx) accepts the schema in one of two equivalent ways:

1. As an inline PHP array, via the data argument:

Under the hood, the array is json_encoded to a temporary file and read back as JSON — so an inline array and a JSON file are handled identically.

2. As a path to a JSON schema file, via the filename argument:

You must pass at least one of data or filename — an exception is thrown if neither is provided. If both are given, data takes precedence.

A JSON file can also contain multiple named schemas (top-level keys), and you extract a specific one via the section argument:

Working with different target types

The same schema works unchanged against any of the three supported target shapes — only how path is resolved differs internally (array key lookup vs. object/model property access):

Output formats

Running the tests


All versions of models-data-extractor with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ^13.0
php Version ^8.4
openspout/openspout Version ^4.23
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 akosnoavek/models-data-extractor contains the following files

Loading the files please wait ...