Download the PHP package tomkyle/transposer without Composer

On this page you can find all versions of the php package tomkyle/transposer. 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 transposer

tomkyle/transposer

PHP Version

A lightweight, zero-dependency utility class for transposing two-dimensional associative arrays. Converts nested data structures from [category][field] => value format into [field][label => field, category => value] format, making the data suitable for table display where fields become rows and categories become columns.

Installation

Install via Composer:

Requirements

Overview

The IterableTransposer performs matrix-like transposition on associative arrays or iterables. It is particularly useful for transforming data that is grouped by categories into a format that can be easily displayed in tables or exported to formats like CSV.

Basic Usage

The constructor accepts an optional label for the first column of the transposal result, which can be used to describe the fields. If no label is provided, the first column will not have a label. In this example, we will use the label "Metric" for the first column in the transposed array which carries the 1st-level key names (e.g., "revenue", "orders" …).

Output:

Constructor Options

The constructor can take an optional label parameter that will be used as the header for the first column in the transposed result. If no label is provided, the first column will not have such a label.

First column will be labeled “Field Name”:

Method Parameters

__invoke($inputArr, $label = null)

Integration Examples

After tranposal, the data can be used in various formats such as Markdown tables, Symfony Console tables, or exported to CSV. Its result looks like so:

The result as a Markdown table would look like this:

With Symfony Console Tables

CSV Export

Error Handling

The IterableTransposer is designed to be robust and handles edge cases gracefully:

Testing

Run the test suite:

Run tests with coverage:

Run static analysis:

Development

This project follows PSR-12 coding standards and includes:

Setup Development Environment

Development Workflow

The project uses npm scripts for development tasks:

File Watching

The watch command monitors source and test files for changes and automatically runs the appropriate tools:

Performance Considerations

API Reference

IterableTransposer::__construct(?string $label = null)

Creates a new transposer instance with an optional default label.

IterableTransposer::__invoke(iterable $inputArr, ?string $label = null): array

Transposes the input array and returns the result.

Parameters:

Returns: Transposed associative array

Throws: No exceptions; returns empty array for invalid input

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Guidelines

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

All notable changes to this project will be documented in the CHANGELOG.md file.

Support


All versions of transposer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
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 tomkyle/transposer contains the following files

Loading the files please wait ....