定制 aladler/laravel-pennant-session-and-db-driver 二次开发

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

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

aladler/laravel-pennant-session-and-db-driver

最新稳定版本:v0.1.3

Composer 安装命令:

composer require aladler/laravel-pennant-session-and-db-driver

包简介

A 'session & DB driver' for Laravel Pennant for feature flags pre and post user authentication.

README 文档

README

Build Status Total Downloads Latest Stable Version License

Introduction

A 'session & DB driver' for Laravel Pennant for feature flags pre- and post-user authentication.

Requirements

  • Laravel 10 or higher
  • PHP 8.1 or higher
  • Pennant 1.6 or higher

Installation

You can install the package via composer:

composer require aladler/laravel-pennant-session-and-db-driver

Add the driver to your config/pennant.php file:

'stores' => [

    'session_and_database' => [
        'driver' => 'session_and_database',
        'table' => 'features',
    ],

],

Register the driver using Pennant's extend method (this can be done in the AppServiceProvider's boot method)

public function boot(): void
{
    Feature::extend('session_and_database', function (){
        return new SessionAndDatabaseDriver(
            app()['db'],
            app()['events'],
            config(),
            [],
            app()['session']
        );
    });
}

If you wish this driver to be the default driver, change the default value in config/pennant.php to session_and_database.

'default' => env('PENNANT_STORE', 'session_and_database'),

or put it in your .env file

PENNANT_STORE=session_and_database

Your User model (or any other Authenticatable) must implement the Aladler\LaravelPennantSessionAndDbDriver\Contracts\UserThatHasPreRegisterFeatures interface.

class User extends Authenticable implements UserThatHasPreRegisterFeatures

Usage

You can activate features for guests and after authentication, the feature will be persisted in the database. Or if a feature is activated when a user is logged in, if they log out (or the session times out in the same device), the feature will still be active for them. This allows, for example, to a/b tests features on the registration flow and keep the same experience after registration is completed.

License

This open-sourced software is licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-29