This PHP library will automatically parse a CSV file and generate a search interface, displaying results in a table.
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.
Artist,Title,Year,Genre America,America,1971,Rock Eric Andersen,Bout Changes 'n' Things Take 2,1966,Rock
composer require markfullmer/datainterface
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
$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.
echo $app->options['title']; echo $app->buildForm(); echo $app->buildTable();