switon/principal 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

switon/principal

Composer 安装命令:

composer require switon/principal

包简介

Runtime contracts for resolved caller identity and tenant state after boundary resolution for Switon Framework

README 文档

README

Principal CI PHP 8.3+

Switon's request-local identity and tenant state for auth checks and tenant-aware flows.

Highlights

  • Request-scoped identity: each request keeps its own guest or authenticated user state.
  • Tenant state: the resolved tenant stays available for later checks without re-resolving it.
  • Explicit boundary writes: auth and tenant resolution can seed or clear the current request state.
  • Stable tenant key: apps can keep a public tenant code separate from the internal tenant ID.
  • Mutable request state: identity and tenant data stay local to the current request.

Installation

composer require switon/principal

Quick Start

use Switon\Core\Attribute\Autowired;
use Switon\Principal\IdentityInterface;
use Switon\Principal\TenantInterface;

final class AuthBoundary
{
    #[Autowired] protected IdentityInterface $identity;
    #[Autowired] protected TenantInterface $tenant;

    public function bootstrap(): void
    {
        $this->identity->set(7, 'mark', ['admin']);
        $this->tenant->set('acme', 'acme');
    }
}

final class ProfileController
{
    #[Autowired] protected IdentityInterface $identity;
    #[Autowired] protected TenantInterface $tenant;

    public function indexAction(): array
    {
        return [
            'user_id' => $this->identity->isGuest() ? null : $this->identity->getId(),
            'tenant' => $this->tenant->hasTenant() ? $this->tenant->getCode() : null,
        ];
    }
}

Docs: https://docs.switon.dev/latest/principal

License

MIT.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固