switon/principal
Composer 安装命令:
composer require switon/principal
包简介
Runtime contracts for resolved caller identity and tenant state after boundary resolution for Switon Framework
README 文档
README
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
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-07