switon/principal

Identity and tenant runtime contracts for Switon (standalone)

Maintainers

Package info

github.com/switon-php/principal

Documentation

pkg:composer/switon/principal

Statistics

Installs: 24

Dependents: 7

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-10 01:54 UTC

This package is auto-updated.

Last update: 2026-05-10 01:58:16 UTC


README

Identity and tenant runtime contracts for Switon Framework.

Installation

composer require switon/principal

Requirements: PHP 8.3+

Quick Start

namespace App\Controller;

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

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.