定制 agilesdesign/pseudo 二次开发

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

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

agilesdesign/pseudo

Composer 安装命令:

composer require agilesdesign/pseudo

包简介

Guest user library for Laravel

README 文档

README

Guest user library for Laravel

Branch
master build status coverage report
dev build status coverage report

Description

pseudo adds the ability for guests permissions within Laravel's authentication functionality.

Installation

Include through composer

composer require agilesdesign/pseudo

Add to provider list
'providers' => [
    Pseudo\Providers\PseudoServiceProvider::class,
];

Overview

Comparison to default Laravel behavior

Auth::check() // true if User false if Pseudo/Contracts/GuestContract 
Auth::user() // returns instance of Pseudo/Contracts/GuestContract instead of null if no user found
@can() // no longer automatically fails if not authenticated, allows Gate to be checked

Configuration

Update Guard Driver(s)

config/auth.php

'guards' => [
    // To use with web guard
    'web' => [
        'driver' => 'pseudo',
        'provider' => 'users',
    ],
    
    // To use with api guard
    'api' => [
        'driver' => 'pseudo-token',
        'provider' => 'users',
    ],
],

Register Service Provider

Manually registering the ServiceProvider is only necessary if your Laravel application is version 5.4.* or before. config/app.php

'providers' => [
    /*
     * Package Service Providers...
     */
    \Pseudo\Providers\PseudoServiceProvider::class,
],

Usage

An instance of Pseudo\Auth\Guest is resolved from Laravel's Service Container when Pseudo/Contracts/GuestContract is requested.

This binding is registered in the supplied ServiceProvider:

public function register()
{
    $this->app->bind(GuestContract::class, Guest::class);
}

You may override this by providing your own GuestUser class that implements Pseudo/Contracts/GuestContract and rebinding the interface:

class GuestUser extends User implements GuestContract
{
    //You can override any attribute by using Eloquent Accessors
    public function getNameAttribute(){
        return 'Guest User';
    }
}
this->app->bind(\Pseudo\Contracts\GuestContract::class, \App\GuestUser::class);

Policy checks can still be type-hinted for Laravel's App\User since Pseudo\Auth\Guest extends it.

Example
Gate::define('create-article', function ($user, $article) {
    if($user instanceof Pseudo\Auth\Guest)
    {
      // logic for guest
    }
    else
    {
      // logic for authenticated
    }
});

agilesdesign/pseudo 适用场景与选型建议

agilesdesign/pseudo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.26k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2016 年 11 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 agilesdesign/pseudo 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-22