Download the PHP package monkeyscloud/monkeyslegion-tenancy without Composer

On this page you can find all versions of the php package monkeyscloud/monkeyslegion-tenancy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package monkeyslegion-tenancy

MonkeysLegion Tenancy v2

Enterprise multi-tenant patterns for MonkeysLegion: single-DB with tenant_id scoping, schema-per-tenant, and database-per-tenant. Domain/subdomain identification, tenant-aware cache/queue/storage. Essential for B2B SaaS. Ground-up build for PHP 8.4 with property hooks, backed enums, and zero magic.

Features

Feature Status
Three Isolation Modes Single-DB (tenant_id scoping), Schema-per-Tenant, Database-per-Tenant
Five Resolution Strategies Domain, Subdomain, HTTP Header, URL Path, Query Parameter + Chain
Tenant Context Static per-request holder with scoped run() execution
Entity Scoping #[BelongsToTenant] attribute, automatic WHERE injection, cross-tenant protection
PSR-15 Middleware Auto-resolution → status check → driver activation → cleanup
Lifecycle Management Create, suspend, activate, delete with schema/DB provisioning
Tenant-Aware Cache Transparent key prefixing: tenant:{id}:
Tenant-Aware Queue Per-tenant queue names, payload enrichment, context restoration
Tenant-Aware Storage Path scoping: tenants/{key}/ with traversal protection
Tenant-Aware Session Session key prefixing for shared infrastructure
Migration Orchestration Per-tenant migrations, auto-generated central tenants table
Event System 7 lifecycle + resolution events for audit/telemetry
PHP 8.4 Native Property hooks, backed enums, asymmetric visibility

Requirements

Installation

Architecture

The package is organized into clear namespaces:

Configuration

Copy the example config to your application's config directory:

Isolation Modes

Single Database (single_db)

All tenants share one database. Isolation is achieved via automatic WHERE tenant_id = :current clauses injected by TenantScope.

Best for: SaaS startups, low-to-medium tenant counts, cost-sensitive deployments.

Schema per Tenant (schema)

Each tenant gets a dedicated PostgreSQL schema (or MySQL database). The SchemaDatabaseDriver switches search_path / USE per request.

Best for: Mid-size SaaS, compliance-sensitive industries, moderate isolation needs.

Database per Tenant (database)

Each tenant gets a fully separate database. The SeparateDatabaseDriver routes to a dedicated ConnectionInterface per tenant.

Best for: Enterprise SaaS, maximum isolation, regulated industries (HIPAA, SOC2).

Tenant Resolution

The middleware resolves tenants by trying resolvers in the order configured:

Example: Subdomain Resolution

With base_domain = "example.com":

Request Host Resolved Tenant Key
acme.example.com acme
globex.example.com globex
example.com null (central context)
nested.sub.example.com null (nested not supported)

Tenant Context

The TenantContext is the central access point for the current tenant:

Entity Scoping

Automatic WHERE Injection

Automatic Insert Data

Cross-Tenant Validation

Entity Lifecycle Listener

Lifecycle Management

The TenantManager provides a complete provisioning pipeline:

Auto-Generated Central Table

The tenants table is created automatically by the package:

This creates:

Tenant-Aware Infrastructure

Cache

Queue (Per-Tenant Isolation)

Storage (Path Scoping)

Session

Events

All lifecycle and resolution events extend MonkeysLegion\Events\Event:

Event Dispatched When
TenantResolved Tenant identified from request (includes resolver class)
TenantNotFound Resolution failed (includes host + path)
TenantSwitched Context changed from one tenant to another
TenantCreated New tenant provisioned
TenantSuspended Tenant suspended (includes reason)
TenantActivated Tenant reactivated
TenantDeleted Tenant deleted (includes ID + key)

Middleware Setup

Register the middleware in your HTTP pipeline:

Tenant Entity

The default Tenant entity uses PHP 8.4 property hooks:

Security Posture

Testing

License

MIT © MonkeysCloud


All versions of monkeyslegion-tenancy with dependencies

PHP Build Version
Package Version
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package monkeyscloud/monkeyslegion-tenancy contains the following files

Loading the files please wait ...