flagception/database-activator
Doctrine DBAL-backed activator for Flagception feature flags. Stores flag state in a SQL database (MySQL/Postgres/SQLite), auto-creates the table, and supports connection arrays, DSNs, or an existing DBAL instance, with customizable table/column names.
flagception_features table (or custom schema), minimizing manual setup. Reduces deployment complexity for CI/CD pipelines.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| DBAL Version Lock | Medium | Pin doctrine/dbal:^4.0 in composer.json to avoid breaking changes. |
| PHP 7.4+ Dependency | Low | Most modern Laravel apps (8+) already meet this; upgrade path is straightforward. |
| PostgreSQL Quirks | Low | Parametrized queries (v1.1.1+) mitigate SQL injection risks; test with your dialect. |
| Schema Conflicts | Medium | Validate table/column names pre-deployment (e.g., via Laravel migrations). |
| Connection Resilience | High | Implement retry logic (e.g., exponential backoff) for DB failures. Use DBAL’s built-in connection pooling. |
| Flagception SDK Drift | Medium | Monitor Flagception’s changelog for activator interface changes; test upgrades early. |
Database Schema Strategy:
flagception_features table be shared across services (monolith) or service-specific (microservices)?
service1_feature).description, environment, created_at)?
Performance at Scale:
feature column.flagception:flags).Disaster Recovery:
Flagception SDK Compatibility:
Auditability and Compliance:
updated_at, updated_by)?
feature_flag_audit).Multi-Environment Management:
prod, staging)?
environment column (simplest).feature_flags_prod).FEATURE_ENV=prod).Laravel Native Integration:
config/flagception.php:
'activator' => \Flagception\DatabaseActivator::class,
'activator_config' => [
'connection' => env('DB_CONNECTION', 'mysql'),
'table' => 'feature_flags',
'options' => [
'db_column_state' => 'is_enabled',
],
],
spatie/laravel-feature-flags) if you prefer ORM over DBAL.$flags = DB::table('feature_flags')->where('environment', 'prod')->get();
Microservices:
feature_flags) to avoid collisions. Add a service_name column for multi-service support.auth_* for auth service) or use multi-tenancy (e.g., tenant_id column).flag.updated) for downstream services to react.Serverless:
Pilot Phase (Low Risk):
$manager = new FeatureManager(
new DatabaseActivator($dbal),
new InMemoryActivator(['default' => false]) // Fallback to false
);
Schema Migration:
CREATE TABLE feature_flags (
feature VARCHAR(255) PRIMARY KEY,
state BOOLEAN NOT NULL,
environment ENUM('prod', 'staging', 'dev') DEFAULT 'prod',
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
Schema::create('feature_flags', function (Blueprint $table) {
$table->string('feature')->primary();
$table->boolean('state')->default(false);
$table->enum('environment', ['prod', 'staging', 'dev'])->default('prod');
$table->text('description')->nullable();
$table->timestamps();
});
Data Migration:
$activator = new DatabaseActivator($dbal);
$flags = json_decode(file_get_contents('flags.json'), true);
foreach ($flags as $feature => $state) {
$activator->setFeature($feature, $state);
}
$oldFlags = include 'old_flags.php';
$newFlags = collect(
How can I help you explore Laravel packages today?