2017 © Pedro Peláez
 

library appmetadata

An object to store app metadata backed by a MySQL table

image

battis/appmetadata

An object to store app metadata backed by a MySQL table

  • Friday, August 5, 2016
  • by battis
  • Repository
  • 2 Watchers
  • 0 Stars
  • 267 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

AppMetadata

Latest Version Scrutinizer Code Quality, (*1)

This is one of those things that feels like it should already exist, but my cursory search of the interwebs failed to turn it up: an associative array akin to $_GLOBALS that is backed by a persistent datastore (MySQL in this case, because it's the only thing I ever use, because… lazy, I guess)., (*2)

Usage

Update your composer.json file to include the following., (*3)

{
  "requires": {
    "battis/appmetadata": "~1.0"
  }
}

Handy hint: It always annoys me to have the overhead of documentation, unit tests, etc. for other projects included in mine. Per this answer on Stack Overflow, you can actually buy some small improvement by adding the --prefer-dist flag to composer install and composer update, as in:, (*4)

composer install --prefer-dist

Create an AppMetadata object and treat it as you would any other associative array., (*5)

// instantiate a new mysqli database connection
$sql = new mysqli('localhost', 'root', 's00pers3kr3t', 'demo-db');

// first use (create database tables -- only needs to happen once!)
Battis\AppMetadata::prepareDatabase($sql);

// instantiate our metadata array
$metadata = new Battis\AppMetadata($sql, 'my-unique-app-key');

// store something into the database
$metadata['X'] = 'foobar';

// read something out of the database
echo $metadata['X']; // 'foobar'

// use one metadata value to derive another
$metadata['Y'] = '@X again'
echo $metadata['Y']; // 'foobar again';

// derived values update automagically
$metadata['X'] = 'xoxo';
echo $metadata['Y']; // 'xoxo again';

// remove something from the database
unset($metadata['X']);
echo $metadata['Y']; // '@X again', since no value X to derive from

Complete documentation is available within the package., (*6)

The Versions

05/08 2016

dev-master

9999999-dev

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

05/08 2016

dev-develop

dev-develop

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

22/07 2016

v1.2.2

1.2.2.0

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

22/10 2015

v1.2.1

1.2.1.0

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

05/10 2015

v1.2

1.2.0.0

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

17/08 2015

v1.1.1

1.1.1.0

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

14/08 2015

v1.1

1.1.0.0

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

25/07 2015

v1.0.1

1.0.1.0

An object to store app metadata backed by a MySQL table

  Sources   Download

LGPL-3.0

by Seth Battis

23/06 2015

v1.0

1.0.0.0

An object to store app metadata backed by a MySQL table

  Sources   Download

by Seth Battis