承接 codingpaws/gitlab-feature 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

codingpaws/gitlab-feature

Composer 安装命令:

composer require codingpaws/gitlab-feature

包简介

Use GitLab Feature Flags in your Laravel app

README 文档

README

Use GitLab feature flags in your Laravel app.

Getting Started

  1. Set up feature flags in a project in your GitLab instance.
  2. Install this library in your project.

    composer require codingpaws/gitlab-feature
    
  3. Publish the configuration

    php artisan vendor:publish --provider=CodingPaws\\GitLabFeature\\FeatureServiceProvider
    
  4. Go to your project’s feature flags and click on Configure
    The configure button is next to the "View user lists" and "New feature flag" buttons

  5. Add entries to your .env config
    • GITLAB_INSTANCE_ID to the instance ID shown in the Configure modal
    • GITLAB_API_URL to the API url shown in the Configure modal
    • GITLAB_ENV_NAME to your environment name which you use in your feature flag rollout strategies.

Usage in PHP

When you want to check a feature flag in PHP, such as controllers or models, you can use the Feature class:

use CodingPaws\GitLabFeature\Feature;

if (Feature::enabled('colored_shopping_cart')) {
   echo '<div class="shopping-cart__colored" />';
}

if (Feature::disabled('date-format-24h')) {
   $dateFormat = DATE_FORMAT_AMPM;
}

Usage in Blade

Importing in blade makes the views hard to read. In views you can use the provided helpers methods:

@if(feature_enabled('new_design'))
   <link rel="stylesheet" href="/static/design-2021.css" />
@endif

@unless(feature_disabled('lazyload'))
   <script src="/js/lazyload.min.js" defer async></script>
@endif

Feature flag cache

Feature flags are cached using the Laravel Cache system. This improves your site’s performance and reduces the load on your GitLab instance. The cache duration can be configured in your config/gitlab_feature.php config file using the cache_duration entry. The standard environment variable is GITLAB_CACHE_DURATION. By default, the cache duration is set to 5 minutes.

You can manually clear the cache as well and force a reload of all feature flags by using the refresh method:

use CodingPaws\GitLabFeature\Feature;

Feature::refresh();

Custom User IDs

By default Auth::id() is used to roll out feature flags based on a user’s ID. You can register a custom User ID resolver if you want to roll out the flags based on a different ID or the username:

use CodingPaws\GitLabFeature\UserIdResolver;

class MyIdResolver extends UserIdResolver
{
  public function resolve(): int|string|null
  {
    return Auth::user()?->name;
  }
}

UserIdResolver::register(new MyIdResolver);

Viewing all available feature flags

When debugging problems or working with A/B tests, it can be helpful to see the state of all feature flags. To get a list of all feature flags and whether they are enabled or not, use the all method:

use CodingPaws\GitLabFeature\Feature;

$flags = Feature::all();

echo $flags['cool_feature'] ? 'enabled' : 'disabled';

How to mock feature flags

Mocking of feature flags can be done through Laravel facade mocking of the Feature facade:

use CodingPaws\GitLabFeature\Feature;

Feature::shouldReceive('enabled')
   ->with('cool_feature')
   ->once()
   ->andReturn(true);

Feature::enabled('cool_feature'); // returns `true`

SSL troubleshooting

On certain platforms or depending on your GitLab instance configuration—this does not apply to the GitLab.com SaaS platform—the in-built SSL verification can sometimes cause issues and not work. We’ve had problems in development environments on Windows, even though OpenSSL was installed.

For cases where SSL verification fails, you can disable it by setting the gitlab_feature.disable_verification to true. By default, you can set the GITLAB_DISABLE_VERIFICATION environment variable to true.

codingpaws/gitlab-feature 适用场景与选型建议

codingpaws/gitlab-feature 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.13k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「flag」 「feature」 「gitlab」 「ab test」 「featureflag」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 codingpaws/gitlab-feature 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 codingpaws/gitlab-feature 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 5.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-24