承接 togul/laravel-sdk 相关项目开发

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

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

togul/laravel-sdk

最新稳定版本:2.4.0

Composer 安装命令:

composer require togul/laravel-sdk

包简介

Laravel integration for Togul Feature Flag Service

README 文档

README

Laravel integration layer for the Togul PHP SDK.

Install

composer require togul/laravel-sdk
php artisan vendor:publish --tag=togul-config

Configuration

Add to .env:

TOGUL_API_KEY=your-environment-api-key
TOGUL_ENVIRONMENT=production
TOGUL_TIMEOUT=5
TOGUL_CACHE_TTL=30
TOGUL_FALLBACK_MODE=closed
TOGUL_RETRY_COUNT=2

Usage

Boolean flag (on/off)

Via facade:

use Togul\Laravel\Facades\Togul;

$enabled = Togul::isEnabled('new-dashboard', [
    'user_id' => (string) auth()->id(),
]);

Via dependency injection:

use Togul\TogulClient;

public function __invoke(TogulClient $togul)
{
    $enabled = $togul->isEnabled('new-dashboard', [
        'user_id' => (string) auth()->id(),
    ]);
}

Via middleware:

Route::get('/dashboard', DashboardController::class)
    ->middleware('togul:new-dashboard');

Multi-variant flags

Use typed facade methods to read flag values beyond boolean:

use Togul\Laravel\Facades\Togul;

$context = ['user_id' => (string) auth()->id()];

// String variant
$theme = Togul::evaluateString('ui-theme', $context, fallback: 'default');

// Number variant
$limit = Togul::evaluateNumber('rate-limit', $context, fallback: 100.0);

// Boolean variant
$flag = Togul::evaluateBool('beta-feature', $context, fallback: false);

// JSON variant
$config = Togul::evaluateJSON('feature-config', $context, fallback: null);

Full evaluation result

$result = Togul::evaluateResult('checkout-flow', $context);

$result->enabled;              // bool
$result->flagKey;              // string
$result->valueType;            // 'boolean' | 'string' | 'number' | 'json'
$result->reason;               // string

$result->boolValue(false);
$result->stringValue('');
$result->numberValue(0.0);
$result->jsonValue(null);

Cache invalidation

Togul::invalidateFlag('new-dashboard'); // single flag
Togul::invalidateCache();               // all flags

Notes

  • TOGUL_API_KEY must be an environment API key, not a user JWT.
  • This package wraps togul/php-sdk; evaluation behavior follows the PHP SDK.
  • Typed accessors return the fallback if the flag is disabled or the value type does not match.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固