Updated readme, bins
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,4 @@
 | 
				
			|||||||
/vendor
 | 
					/vendor
 | 
				
			||||||
/composer.lock
 | 
					/composer.lock
 | 
				
			||||||
 | 
					/*.zip
 | 
				
			||||||
 | 
					/.phpunit.cache
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										37
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								README.md
									
									
									
									
									
								
							@@ -1,22 +1,43 @@
 | 
				
			|||||||
# Dataset Library for PHP/Composer
 | 
					# Dataset Library for PHP/Composer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This is a library for loading datasets from bundled packages.
 | 
					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:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```shell
 | 
				
			||||||
 | 
					$ composer require noccylabs/dataset
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You also need some actual datasets. Some interesting ones could be:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Package | Description
 | 
				
			||||||
 | 
					---|---
 | 
				
			||||||
 | 
					[noccylabs/dataset-postal](https://dev.noccylabs.info/noccy/dataset-postal) | Patterns and info for postal (zip) code validation
 | 
				
			||||||
 | 
					[noccylabs/dataset-calendar](https://dev.noccylabs.info/noccy/dataset-calendar) | Bank holidays
 | 
				
			||||||
 | 
					[noccylabs/dataset-iso3166](https://dev.noccylabs.info/noccy/dataset-iso3166) | ISO 3166 country codes and namess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Example
 | 
					## Example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Require Dataset, and some actual datasets:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    $ composer require noccylabs/dataset juicebox/flavordata
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You can now open the desired sets and do useful stuff with the data:
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
```php
 | 
					```php
 | 
				
			||||||
use NoccyLabs\Dataset\DatasetManager;
 | 
					use NoccyLabs\Dataset\DatasetManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$dm = new DatasetManager();
 | 
					$dm = new DatasetManager();
 | 
				
			||||||
$ds = $dm->getDataset("juicebox/flavordata#flavors");
 | 
					$ds = $dm->getDataset("noccylabs/dataset-iso3166#countries");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
foreach ($ds as $row) {
 | 
					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
 | 
					    // row is an array
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,8 +2,9 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
foreach ([
 | 
					foreach ([
 | 
				
			||||||
 | 
					    __DIR__."/..",
 | 
				
			||||||
    __DIR__."/../vendor",
 | 
					    __DIR__."/../vendor",
 | 
				
			||||||
    __DIR__."/../../../vendor",
 | 
					    __DIR__."/../../..",
 | 
				
			||||||
    __DIR__."/vendor",
 | 
					    __DIR__."/vendor",
 | 
				
			||||||
] as $dir) {
 | 
					] as $dir) {
 | 
				
			||||||
    if (file_exists($dir."/autoload.php")) {
 | 
					    if (file_exists($dir."/autoload.php")) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user