Download the PHP package alexskrypnyk/csvtable without Composer

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

CsvTable logo

PHP class to parse and format CSV content

[![GitHub Issues](https://img.shields.io/github/issues/AlexSkrypnyk/CsvTable.svg)](https://github.com/AlexSkrypnyk/CsvTable/issues) [![GitHub Pull Requests](https://img.shields.io/github/issues-pr/AlexSkrypnyk/CsvTable.svg)](https://github.com/AlexSkrypnyk/CsvTable/pulls) [![Test PHP](https://github.com/AlexSkrypnyk/CsvTable/actions/workflows/test-php.yml/badge.svg)](https://github.com/AlexSkrypnyk/CsvTable/actions/workflows/test-php.yml) [![codecov](https://codecov.io/gh/AlexSkrypnyk/CsvTable/graph/badge.svg?token=7WEB1IXBYT)](https://codecov.io/gh/AlexSkrypnyk/CsvTable) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/AlexSkrypnyk/CsvTable) ![LICENSE](https://img.shields.io/github/license/AlexSkrypnyk/CsvTable) ![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot)

✨ Features

📋 Requirements

PHP 8.3 or newer. The class uses only the PHP standard library, so CsvTable.php can also be dropped into a project that does not use Composer.

📦 Installation

The class is AlexSkrypnyk\CsvTable\CsvTable.

🚀 Usage

Given a CSV file with the following content:

From string

will produce identical CSV content by default:

From file

will produce identical CSV content by default:

fromFile() throws an Exception when the file is missing or cannot be read.

Reading the parsed data

parse() populates the header and the rows, which are then available through getHeader() and getRows(). Calling format() parses the content automatically, so parse() is only needed when reading the data directly.

Custom separator, enclosure and escape characters

The constructor and fromFile() both accept the separator, enclosure and escape characters used to read the content. They default to ,, " and \.

These characters apply to parsing only. The csv formatter writes using its own separator, enclosure and escape options, so semicolon-separated input is written back as comma-separated content unless the formatter is told otherwise:

Using table formatter

will produce table content:

Using table formatter without a header

will produce table content:

withHeader() restores the default behaviour of treating the first row as a header.

Using markdown_table formatter

will produce Markdown table:

Formatter options

Options are passed as the second argument to format() and are merged over the defaults below.

Formatter Option Default Description
csv separator , Character written between values.
csv enclosure " Character used to enclose values.
csv escape \ Character used to escape special characters.
table column_separator \| String written between columns.
table row_separator \n String written between rows.
markdown_table column_separator \| String written between columns.
markdown_table row_separator \n String written between rows.
markdown_table header_separator - Character filling the row under the header.
markdown_table value_row_separator <br/> Replaces newlines found within a value.

will produce:

Custom formatter as an anonymous callback

A formatter receives the header columns, the rows and the options, and returns the formatted string.

will produce:

Custom formatter as a class with default format method

When a class name is passed, its static format() method is called.

Custom formatter as a class with a custom method and options

format() throws an Exception when the value passed to it cannot be resolved to a callable.

🔀 Column Manipulation

Given a CSV file with the following content:

Reorder columns with columnOrder()

Reorder columns by specifying the desired order. Columns not specified are appended in their original order.

will produce:

Filter to specific columns with onlyColumns()

Keep only the specified columns in the output, in the order specified.

will produce:

Exclude columns with withoutColumns()

Exclude specified columns from the output. The remaining columns keep their original order.

will produce:

Using column indices

All column methods accept both column names (strings) and zero-based indices (integers). An unknown name or an out-of-range index throws an InvalidArgumentException.

Names are resolved against the header, so content parsed with withoutHeader() can only be addressed by index.

Combining column transformations

Column transformations are applied in order: onlyColumns() → withoutColumns() → columnOrder().

will produce:

Reset column transformations

resetColumns() clears all three transformations at once. resetColumnOrder(), resetOnlyColumns() and resetWithoutColumns() clear them individually.

🤝 Contributing

See CONTRIBUTING.md for local development setup and the linting and testing commands.

🔄 Updating

To pull the latest infrastructure from the template into this project, ask Claude Code to "update scaffold" - see AGENTS.md for details.


This repository was created using the Scaffold project template


All versions of csvtable 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 alexskrypnyk/csvtable contains the following files

Loading the files please wait ...