Auto-Parsing Data Search Interface

https://github.com/markfullmer/datainterface

This PHP library will automatically parse a CSV file and generate a search interface, displaying results in a table.

Examples

The library takes a CSV file with a header row as its input, as well as arguments for which column names should be filterable and which columns should display in the table. The library provides two main methods for rendered output: the form, and the table.

Specifications & Usage

  1. Create a standard-format CSV file with a header row. A simple example is below:
Artist,Title,Year,Genre
America,America,1971,Rock
Eric Andersen,Bout Changes 'n' Things Take 2,1966,Rock
  1. Add this PHP library to your project in the standard way:
composer require markfullmer/datainterface
  1. Instantiate the data as a PHP class object. In the example below, the code is being instructed to create a filter for 'Year' and 'Genre' (but not 'Artist') and to display 'Artist', 'Title', and 'Year' in the table:
use markfullmer\datainterface\DataInterface;

$app = new DataInterface([
  'file' => 'records.csv',
  'title' => 'List of LPs',
  'filters' => ['Year', 'Genre'],
  'table_columns' => ['Artist', 'Title', 'Year'],
]);

The library also supports reading CSV data over HTTP (including public, published Google Sheets as CSV). To use this approach, provide a url parameter:

$app = new DataInterface([
  'file' => 'https://example.com/records.csv',
  'title' => 'List of LPs',
  'filters' => ['Year', 'Genre'],
  'table_columns' => ['Artist', 'Title', 'Year'],
]);

If reading data over HTTP, the library stores the URL in the filesystem for performance reasons. To refresh the request, add ?reset to the website URL.

  1. Render the parts of the interface as desired:
echo $app->options['title'];
echo $app->buildForm();
echo $app->buildTable();

Features

Possible enhancements