inmanturbo/features
Composer 安装命令:
composer require inmanturbo/features
包简介
Pluggable feature system built on top of laravel/pennant
README 文档
README
A pluggable feature system built on top of Laravel Pennant.
Installation
Install the package via Composer:
composer require inmanturbo/features
The service provider will be automatically registered thanks to Laravel's package auto-discovery.
Configuration
Defined-Database Driver
This package uses a custom defined-database driver that only retrieves features that have been explicitly defined. This allows removing features without losing any data, fetures can be redefined later with their data still intact.
The published Pennant config sets this as the default driver:
'default' => env('PENNANT_DRIVER', 'defined-database'),
Usage
Before Hooks
use Laravel\Pennant\Feature; Feature::before('new-api', function (User $user) { if (Config::get('features.new-api.disabled')) { return $user->isInternalTeamMember(); } });
Resetting Feature Defaults
Using the Artisan Command
The package provides a convenient feature:reset Artisan command to reset features interactively or via command line options.
Interactive Mode
Run the command without options for an interactive experience:
php artisan feature:reset
When features exist in your database, the command will:
- Auto-discover available scopes and features from your database
- Present interactive menus to select:
- A specific scope or "[All Scopes]"
- A specific feature or "[All Features]"
- Safely reset only the selected combination
If no features exist in the database, it will immediately reset (no-op) without prompting.
Command Line Options
Skip the interactive prompts by providing explicit options:
# Reset all features for all scopes (when database is empty) php artisan feature:reset # Reset all features for a specific scope php artisan feature:reset --scope="user:1" # Reset a specific feature for all scopes php artisan feature:reset --feature="new-dashboard" # Reset a specific feature for a specific scope php artisan feature:reset --scope="user:1" --feature="new-dashboard" # Reset non-existent features (safe no-op) php artisan feature:reset --scope="nonexistent" --feature="missing"
Use Cases
The feature:reset command is useful for:
- Development: Quickly reset feature flags during testing
- Debugging: Remove problematic feature overrides to fall back to defaults
- Data cleanup: Clear old or unused feature flag data
- User management: Reset features for specific users or teams
- Feature rollback: Revert features to their default state after experiments
Using the FeatureRegistry Class
The FeatureRegistry class provides a resetDefaults method to remove feature flags from the database, allowing them to fall back to their default values:
use Inmanturbo\Features\FeatureRegistry; // Reset all features for all scopes FeatureRegistry::resetDefaults(); // Reset all features for a specific scope (user, team, etc.) FeatureRegistry::resetDefaults(scope: $user); // Reset a specific feature for all scopes FeatureRegistry::resetDefaults(name: 'feature-name'); // Reset a specific feature for a specific scope FeatureRegistry::resetDefaults(scope: $user, name: 'feature-name');
This is useful when you want to:
- Remove overridden feature values and revert to defaults
- Clean up test data
- Reset features during development
Credits
This package is built on top of Laravel Pennant, Laravel's official feature flag package.
License
MIT
inmanturbo/features 适用场景与选型建议
inmanturbo/features 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 09 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 inmanturbo/features 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inmanturbo/features 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 52
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-11