No description
Find a file
Snider 501ea1897e chore: add strict types to core files (P2-019)
- Add declare(strict_types=1) to Workspace.php
- Add declare(strict_types=1) to User.php
- Add declare(strict_types=1) to EntitlementService.php

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 15:16:10 +00:00
.gemini Initial commit 2026-01-26 21:03:15 +00:00
.github monorepo sepration 2026-01-27 00:31:43 +00:00
changelog/2026/jan refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Concerns security: fix P1 items for rate limiting, auth, SSRF and workspace validation 2026-01-29 13:19:27 +00:00
Console/Commands security: encrypt 2FA secrets and hash invitation tokens 2026-01-29 12:20:53 +00:00
Contracts refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Controllers security: fix P1 items for rate limiting, auth, SSRF and workspace validation 2026-01-29 13:19:27 +00:00
Database security: encrypt 2FA secrets and hash invitation tokens 2026-01-29 12:20:53 +00:00
docs security: encrypt 2FA secrets and hash invitation tokens 2026-01-29 12:20:53 +00:00
Enums refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Events/Webhook refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Exceptions security: fix P1 items for rate limiting, auth, SSRF and workspace validation 2026-01-29 13:19:27 +00:00
Features refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Jobs refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Lang/en_GB fix: namespace to Core\Mod\Tenant, restructure package 2026-01-27 00:58:42 +00:00
Listeners refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Mail refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Middleware security: fix P1 items for rate limiting, auth, SSRF and workspace validation 2026-01-29 13:19:27 +00:00
Migrations fix: namespace to Core\Mod\Tenant, restructure package 2026-01-27 00:58:42 +00:00
Models chore: add strict types to core files (P2-019) 2026-01-29 15:16:10 +00:00
Notifications security: encrypt 2FA secrets and hash invitation tokens 2026-01-29 12:20:53 +00:00
Routes refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Rules refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Scopes refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
Services chore: add strict types to core files (P2-019) 2026-01-29 15:16:10 +00:00
tests/Feature security: encrypt 2FA secrets and hash invitation tokens 2026-01-29 12:20:53 +00:00
View refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
.editorconfig Initial commit 2026-01-26 21:03:15 +00:00
.gitattributes Initial commit 2026-01-26 21:03:15 +00:00
.gitignore Initial commit 2026-01-26 21:03:15 +00:00
AGENTS.md Initial commit 2026-01-26 21:03:15 +00:00
Boot.php security: encrypt 2FA secrets and hash invitation tokens 2026-01-29 12:20:53 +00:00
CLAUDE.md docs: update CLAUDE.md with correct namespace and architecture details 2026-01-28 14:16:40 +00:00
cliff.toml Initial commit 2026-01-26 21:03:15 +00:00
composer.json refactor: rename namespace from Core\Mod\Tenant to Core\Tenant 2026-01-27 16:30:46 +00:00
GEMINI.md Initial commit 2026-01-26 21:03:15 +00:00
LICENSE Initial commit 2026-01-26 21:03:15 +00:00
README.md monorepo sepration 2026-01-27 00:31:43 +00:00
TODO.md chore: add strict types to core files (P2-019) 2026-01-29 15:16:10 +00:00

Core Tenant

CI PHP Version Laravel License

Multi-tenancy module for the Core PHP Framework providing users, workspaces, and entitlements.

Features

  • Users & Authentication - User management with 2FA support
  • Workspaces - Multi-tenant workspace boundaries
  • Entitlements - Feature access, packages, and usage tracking
  • Account Management - User settings, account deletion
  • Referrals - Referral system support
  • Usage Alerts - Configurable usage threshold alerts

Requirements

  • PHP 8.2+
  • Laravel 11.x or 12.x
  • Core PHP Framework (host-uk/core)

Installation

composer require host-uk/core-tenant

The service provider will be auto-discovered.

Run migrations:

php artisan migrate

Usage

Workspace Management

use Core\Mod\Tenant\Services\WorkspaceManager;
use Core\Mod\Tenant\Services\WorkspaceService;

// Get current workspace
$workspace = app(WorkspaceManager::class)->current();

// Create a new workspace
$workspace = app(WorkspaceService::class)->create([
    'name' => 'My Workspace',
    'owner_id' => $user->id,
]);

Entitlements

use Core\Mod\Tenant\Services\EntitlementService;

$entitlements = app(EntitlementService::class);

// Check if workspace has access to a feature
if ($entitlements->hasAccess($workspace, 'premium_feature')) {
    // Feature is enabled
}

// Check usage limits
$usage = $entitlements->getUsage($workspace, 'api_calls');

Middleware

The module provides middleware for workspace-based access control:

// In your routes
Route::middleware('workspace.permission:manage-users')->group(function () {
    // Routes requiring manage-users permission
});

Models

Model Description
User Application users
Workspace Tenant workspace boundaries
WorkspaceMember Workspace membership with roles
Entitlement Feature/package entitlements
UsageRecord Usage tracking records
Referral Referral tracking

Events

The module fires events for key actions:

  • WorkspaceCreated
  • WorkspaceMemberAdded
  • WorkspaceMemberRemoved
  • EntitlementChanged
  • UsageAlertTriggered

Artisan Commands

# Refresh user statistics
php artisan tenant:refresh-user-stats

# Process scheduled account deletions
php artisan tenant:process-deletions

# Check usage alerts
php artisan tenant:check-usage-alerts

# Reset billing cycles
php artisan tenant:reset-billing-cycles

Configuration

The module uses the Core PHP configuration system. Key settings can be configured per-workspace or system-wide.

Documentation

License

EUPL-1.2 (European Union Public Licence)