flagception/database-activator
Composer 安装命令:
composer require flagception/database-activator
包简介
Activator for manage feature toggles via database
关键字:
README 文档
README
Manage feature flags for Flagception with a sql database (mysql, postgres, sqlite, ...)!
Download the library
Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:
$ composer require flagception/database-activator
Usage
Just create a new DatabaseActivator instance and commit it to your feature manager:
// YourClass.php
class YourClass
{
public function run()
{
$activator = new DatabaseActivator('pdo-mysql://user:secret@localhost/mydb');
$manager = new FeatureManager($activator);
if ($manager->isActive('your_feature_name')) {
// do something
}
}
}
Connection
This activator use dbal under the hood. We redirect the first argument directly to dbal - so you can use all known connection options (see documentation):
User and password
// YourClass.php
class YourClass
{
public function run()
{
$activator = new DatabaseActivator([
'dbname' => 'mydb',
'user' => 'user',
'password' => 'secret',
'host' => 'localhost',
'driver' => 'pdo_mysql'
]);
// ...
}
}
Connection string
// YourClass.php
class YourClass
{
public function run()
{
$activator = new DatabaseActivator('pdo-mysql://user:secret@localhost/mydb');
// ...
}
}
DBAL instance
// YourClass.php
class YourClass
{
public function run()
{
$activator = new DatabaseActivator($this->myDbalInstance);
// ...
}
}
Table
The activator will create the sql table if it does not already exist. The default table name is flagception_features which contains
a feature and a state column. You can change the table and columns names by the second argument. It expects
an array with values for db_table, db_column_feature and db_column_state. Setting one of the fields in optional.
Example:
// YourClass.php
class YourClass
{
public function run()
{
$activator = new DatabaseActivator('pdo-mysql://user:secret@localhost/mydb', [
'db_table' => 'my_feature_table',
'db_column_feature' => 'foo_feature_name',
'db_column_state' => 'foo_is_active'
]);
// The activator create a table 'my_feature_table' with the column 'foo_feature_name' and 'foo_is_active'.
$manager = new FeatureManager($activator);
if ($manager->isActive('your_feature_name')) {
// do something
}
}
}
flagception/database-activator 适用场景与选型建议
flagception/database-activator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 475.89k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「dbal」 「sql」 「mysql」 「sqlite」 「doctrine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 flagception/database-activator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 flagception/database-activator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 flagception/database-activator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Query filtering in your frontend
A custom Doctine DBAL type to use PHP DateTime objects set to the system's default timezone.
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 475.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 29
- 依赖项目数: 3
- 推荐数: 4
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-07