Skip to content

switon-php/principal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Switon Principal Package

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages