定制 inmanturbo/features 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

inmanturbo/features

Composer 安装命令:

composer require inmanturbo/features

包简介

Pluggable feature system built on top of laravel/pennant

README 文档

README

Latest Version on Packagist Tests Total Downloads License

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:

  1. Auto-discover available scopes and features from your database
  2. Present interactive menus to select:
    • A specific scope or "[All Scopes]"
    • A specific feature or "[All Features]"
  3. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 inmanturbo/features 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 52
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 20
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-11