battis/appmetadata
最新稳定版本:v1.2.2
Composer 安装命令:
composer require battis/appmetadata
包简介
An object to store app metadata backed by a MySQL table
README 文档
README
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).
Usage
Update your composer.json file to include the following.
{
"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:
composer install --prefer-dist
Create an AppMetadata object and treat it as you would any other associative array.
// 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.
统计信息
- 总下载量: 317
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2015-06-20