Download the PHP package survos/key-value-bundle without Composer
On this page you can find all versions of the php package survos/key-value-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download survos/key-value-bundle
More information about survos/key-value-bundle
Files in survos/key-value-bundle
Package key-value-bundle
Short Description Symfony Bundle to easily allow a SQLite Key Value lookup
License MIT
Informations about the package key-value-bundle
Key Value Bundle
A Symfony bundle that leverages Sqlite to create an indexed no-sql datastore.
Inspired by https://gist.github.com/sbrl/c3bfbbbb3d1419332e9ece1bac8bb71c and https://dexie.org/ and the Symfony PDO Cache component.
At its core, the idea is to store strings or unstructured data accessible by a key or a filter.
Initially, it was just a string lookup, which could be a JSON string, for example looking up a wikidata object by its QID, or a movie from a csv file by its imdb_id.
You can customize the import process by adding a .conf file with directives that facilitate renaming fields and munging data. You can also listen for events during the import and export process.
Pixy can (will, eventually) use json schema files to defining the fields. https://json-schema.org/ using LiFormBundle
The indexes can be defined via the command line, a listener, or a .conf file. There's a succinct format that is a comma-separated string, and a detailed format with is a hash with the index details as keys.
There is (will be) an API endpoint if api-platform is installed.
Integration with survos/translation-bundle
Setup
All pixy db files have an associated configuration file that describes the mapping and underlying data structure. Generally it shares the same base filename.
"Special" Tables
Since pixy databases offer a convenient way to work with Excel data, there is a special table for handling drawings (embedded images). It is created with bin/console grid:excel-to-csv (in the grid-group bundle? In museado?)
Excel stores embedded images as "Drawings".
Translations are also stored as pixy tables, and have their own section.
Examples
- Movies (imdb)
- Schools
CSV Datasets
- https://www.stats.govt.nz/large-datasets/csv-files-for-download/
-
Reading an Existing Pixy
The conf file simplifies some of the php calls, but isn't 100% necessary
Suppose we want to filter by category. First, we need to add an index, dexie-style, to the table.
Often CSV files and other data sources have key names that aren't really compatible with sqlite column names. To map the old names to the new ones, you can create a sequence of regex rules for the column names.
From MOMA Artists.json
All fields will be converted to camel_case, even without regex rules.
Note that the JSON is NOT compressed, so the keys are duplicated. So the sqlite file is larger than the CSV by (rowCount * headerRowSize).
Usage
Initialize StorageBox with the sqlite database name plus any new tables to be created.
Existing tables can be used, but automatic table creation is disabled.
Multi-lingual StorageBox
Specifically for kv lookups of text fields that may have translations
$kvDb = new MLSB('property.db', ['label','description']);
$key = 'Q31';
$kvDb->set($key, 'label', 'Belgium', 'en-gb');
$kvDb->set($key, 'description', 'constitutional monarchy in Western Europe', 'en-gb');
$transArray = $kvDb->getFieldsByLocale($key, 'en-gb');
// ['label' => 'Belgium'...]
$label = $kvDb->getField($key, 'label', 'en-gb');
// 'Belgium'
$transArray = $kvDb->getFields($key);
// ['en-gb' => ['label' => 'Belgium', 'description' => ...]]
// ditto for set, needs transactions
All versions of key-value-bundle with dependencies
php Version ^8.2
symfony/config Version ^6.4 || ^7.0
symfony/dependency-injection Version ^6.4 || ^7.0
symfony/http-kernel Version ^6.4 || ^7.0
twig/twig Version ^3.4
endroid/installer Version ^1.4