enlivenapp/flight-settings
Composer 安装命令:
composer require enlivenapp/flight-settings
包简介
Database-backed key-value settings for FlightPHP, ported from CodeIgniter Settings
README 文档
README
flight-settings
I noticed folks downloading some of these packages. I'm super grateful, Thank You! I would like to let folks know until this notice disappears I'm doing a lot of breaking changes without worrying about them. Once versions are up around 0.5.x things should settle down.
A settings store for FlightPHP, built as a Flight School plugin. Values live in the database, get cached for the request, and keep their PHP types — write an int, read an int back.
What you get
- Simple
get()/set()/forget()API onFlight::settings(). - Keys like
'Site.name'or'Auth.allowRegistration', grouped by the part preceeding the dot. - Per-user, per-tenant, or any other scope — pass a
contextstring. - One query per scope per request. Everything after that comes from memory.
Requirements
- PHP 8.1+
flightphp/core^3.0enlivenapp/flight-school^0.2enlivenapp/migrationsflightphp/active-record
Install
composer require enlivenapp/flight-settings
Enable it in app/config/config.php:
'plugins' => [ 'enlivenapp/flight-settings' => [ 'enabled' => true, 'priority' => 20, ], ],
That's it. On the next page load, enlivenapp/migrations creates the settings table and seeds CMS.siteName and CMS.siteByline as baseline rows.
Flight School reads this package's src/Config/Config.php as a returned array and stores it on $app under enlivenapp.flight-settings. That file currently returns 'routePrepend' => null, so the package does not register a public route prefix.
Quick start
$settings = Flight::settings(); $name = $settings->get('CMS.siteName'); //null $name = $settings->get('CMS.siteByline'); //null $settings->set('CMS.siteName', 'My App'); $settings->set('CMS.siteByline', 'Do Great Things!'); $name = $settings->get('CMS.siteName'); // 'My App' $name = $settings->get('CMS.siteByline'); // Do Great Things!
get() returns null when the key isn't in the database.
Keys
Dot notation: the part before the dot is the group, the part after is the property. Both are required — a key without a dot throws InvalidArgumentException.
$settings->get('Auth.allowRegistration'); // group = Auth, property = allowRegistration $settings->get('Mail.fromAddress');
Contexts
A context lets the same setting hold different values for different things. You pick any string that identifies what the setting belongs to, and pass it as the context argument. Examples of what a context could be:
- A user ID → this setting belongs to user
42 - A site code (if one app serves multiple sites) → this setting is for site
westcoast - A customer or organization ID → this setting belongs to
ACME Corp - A language code → this setting is for the Spanish version
Every row in the settings table has an optional context column. Writing with a context ties the row to that string; reading with the same string returns that row. Reading with no context returns the general (site-wide) row.
$settings->set('User.theme', 'dark', context: (string) $userId); $settings->get('User.theme', context: (string) $userId); $settings->forget('User.theme', context: (string) $userId);
get() with a context returns only that context's row, or null if there isn't one.
Types
A database column doesn't remember PHP types. Save true and you usually read back "1". Save 20 and you read back "20". This plugin records the type next to the value so the cast is done for you on read — what you put in is what you get back.
$settings->set('Site.itemsPerPage', 20); $settings->get('Site.itemsPerPage'); // 20 — integer, not "20" $settings->set('Auth.allowRegistration', true); $settings->get('Auth.allowRegistration'); // true — boolean, not "1"
Supported: string, integer, double (float), boolean, array, object, NULL. Arrays and objects are stored via PHP's serialize() and restored with unserialize() — so you can stash small structured values, just don't treat it like a document store.
API
All methods on Flight::settings():
| Method | Signature | What it does |
|---|---|---|
get |
get(string $key, ?string $context = null): mixed |
Read. Returns null if not in the database. |
set |
set(string $key, mixed $value = null, ?string $context = null): void |
Write. Cache updates immediately. |
has |
has(string $key, ?string $context = null): bool |
Does a database row exist? |
forget |
forget(string $key, ?string $context = null): void |
Delete one row. |
Schema
The migration creates a settings table:
| Column | Type | Notes |
|---|---|---|
id |
int | Primary key |
class |
varchar(255) | Part before the dot |
key |
varchar(255) | Part after the dot |
value |
text, nullable | Serialized value |
type |
varchar(31) | PHP type, used for cast-back |
context |
varchar(255), nullable | Scope string; NULL = general |
created_at |
datetime, nullable | |
updated_at |
datetime, nullable |
Composite index on (class, key, context).
License
MIT — see LICENSE.
enlivenapp/flight-settings 适用场景与选型建议
enlivenapp/flight-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 enlivenapp/flight-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 enlivenapp/flight-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-18