Bundles static data as composer dependencies
Go to file
Chris d0956f851c Initial unit tests, code cleanup 2022-10-31 00:42:29 +01:00
bin Initial unit tests, code cleanup 2022-10-31 00:42:29 +01:00
example Initial commit 2022-09-03 02:28:03 +02:00
src Initial unit tests, code cleanup 2022-10-31 00:42:29 +01:00
tests Initial unit tests, code cleanup 2022-10-31 00:42:29 +01:00
.gitignore Updated readme, bins 2022-10-30 23:21:53 +01:00
LICENSE Initial commit 2022-09-03 02:28:03 +02:00
README.md updated readme 2022-10-30 23:24:27 +01:00
composer.json Initial unit tests, code cleanup 2022-10-31 00:42:29 +01:00
phpstan.neon Initial unit tests, code cleanup 2022-10-31 00:42:29 +01:00
phpunit.xml Initial unit tests, code cleanup 2022-10-31 00:42:29 +01:00

README.md

Dataset Library for PHP/Composer

This is a library for loading datasets from bundled packages. The idea isn't to use the classes in this library as a generic datasource, although you could probably pull that off. Instead, use the datasets to import the relevant data to your database of choice, and optionally keep track of the version numbers so new data can be imported automatically when the dependencies have been updated and a new version has been installed.

Installing

To install dataset, require it using composer:

$ composer require noccylabs/dataset

You also need some actual datasets. Some interesting ones could be:

Package Description
noccylabs/dataset-postal Patterns and info for postal (zip) code validation
noccylabs/dataset-calendar Bank holidays
noccylabs/dataset-iso3166 ISO 3166 country codes and namess

Example

use NoccyLabs\Dataset\DatasetManager;

$dm = new DatasetManager();

// Call on getDataset() if you want access to the metadata,
// Replace with openDataset() to quicly call getDataset()->open()
$ds = $dm->getDataset("noccylabs/dataset-iso3166#countries");

// This is how you get the metadata
echo "Dataset ID: ".$ds->getIdentifier(); // noccylabs/dataset-iso3166#countries
echo "Dataset version: ".$ds->getVersion(); // 2022.10.1

// Get a reader by calling open()
$reader = $ds->open();
foreach ($reader as $row) {
    // row is an array
}