承接 customergauge/session 相关项目开发

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

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

customergauge/session

最新稳定版本:2.2.1

Composer 安装命令:

composer require customergauge/session

包简介

Native PHP Session adapter for Laravel Authentication

README 文档

README

Code Coverage Scrutinizer Code Quality

Laravel PHP Session ⛔

This library provides a NativeSessionUserProvider for Laravel.

Installation

composer require customergauge/session

Usage

Auth configuration

In the auth.php file, add the following settings:

Default Guard

    'defaults' => [
        'guard' => 'php',
        'passwords' => 'users',
    ],

The new Guard configuration

    'guards' => [
        'php' => [
            'driver' => \CustomerGauge\Session\NativeSessionGuard::class,
            'provider' => \CustomerGauge\Session\NativeSessionUserProvider::class,
            'domain' => '.app.mydomain.com',
            'storage' => 'tcp://my.redis.address:6379',
        ],
    ],

Auth Middleware

Configure the auth middleware at App\Http\Kernel with 'auth:php'

UserFactory

The last thing you'll need is to provide your own implementation of UserFactory and register it in a ServiceProvider.

final class NativeSessionUserFactory implements UserFactory
{
    public function make(array $session): ?Authenticatable
    {
        // $session here is the same as $_SESSION
        
        return new MyUserObject(
            $session['id'],
            $session['my_user_attribute'],
        );
    }
}

In the provider:

$this->app->bind(CustomerGauge\Session\Contracts\UserFactory, App\Auth\NativeSessionUserFactory::class);

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 11
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-18