Download the PHP package rasuvaeff/yii3-tenancy without Composer

On this page you can find all versions of the php package rasuvaeff/yii3-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 yii3-tenancy

rasuvaeff/yii3-tenancy

Stable Version Total Downloads Build Static analysis Psalm level PHP Русская версия

Multi-tenancy core for Yii3: tenant resolution from the request (header/subdomain/path), a request-scoped CurrentTenant context, and scoping primitives. Deliberately no ORM auto-scoping magic — explicit primitives and recipes instead.

Using an AI coding assistant? llms.txt contains a compact API reference you can share with the model. Contributors: see AGENTS.md. Projects using the llm/skills Composer plugin also get this package's agent skill synced into .agents/skills/ automatically on install.

Requirements

Requirement Version
PHP 8.3 – 8.5
PSR-7 / PSR-15 / PSR-17 / PSR-16 any implementation

Installation

For persistent tenant storage add the DB backend (planned: rasuvaeff/yii3-tenancy-db) or bind your own TenantProvider.

Usage

Resolution middleware

Place it in the middleware pipeline before authentication — the tenant usually determines the user store. On success the tenant is published twice:

Unresolved/unknown key → 404; suspended tenant → 403. Both are policies (TenantPolicy::Reject | TenantPolicy::PassThrough).

Resolvers

Resolver Source Example
HeaderTenantResolver X-Tenant-Id header (configurable) X-Tenant-Id: acme
SubdomainTenantResolver first label under a configured base domain acme.example.com
PathTenantResolver first segment after a configured prefix /t/acme/dashboard
CompositeTenantResolver chain, first non-null wins header, then subdomain

Every resolver validates the extracted key against Tenant::isValidId() (/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}\z/) and returns null on mismatch — keys taken from requests are untrusted input. Nested subdomains (a.b.example.com) and lookalike hosts (acmeexample.com) resolve to null.

Reading the current tenant

For console/test contexts where one process handles several tenants use RequestCurrentTenant::override().

Tenant-scoped cache

clear() delegates to the inner cache and wipes all tenants — PSR-16 has no prefix-scoped clear. Do not call it in tenant-scoped code paths.

DI configuration (Yii3)

Ships config/di.php + config/params.php via config-plugin. The core binds CurrentTenant, the resolvers, and the middleware. TenantProvider is deliberately not bound — exactly one source binds it: a backend package or your application:

Override params as needed:

Recipes: wiring into the rasuvaeff/* ecosystem

Components

Tenant

Property Type Description
id string validated: /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}\z/
name string optional display name
status TenantStatus Active (default) / Suspended
attributes array<string, mixed> free-form tenant metadata

CurrentTenant / RequestCurrentTenant

Readers depend on the CurrentTenant interface (get(), find(), isResolved()); the middleware depends on the concrete RequestCurrentTenant (set() once per request, override() for console/tests).

TenantResolutionMiddleware

Parameter Type Default Description
resolver TenantResolver key extraction
provider TenantProvider key → Tenant lookup
currentTenant RequestCurrentTenant publication target
responseFactory ResponseFactoryInterface builds 404/403
unresolvedPolicy TenantPolicy Reject unresolved/unknown key
suspendedPolicy TenantPolicy Reject suspended tenant

Security

Examples

See examples/ for a runnable script.

Script Shows Needs server?
resolve-tenant.php Resolution, request attribute, 404/403 policies no

Development

No PHP/Composer on the host — run in Docker via the composer:2 image:

Or with Make: make build, make cs-fix, make psalm, make test.

License

BSD-3-Clause. See LICENSE.md.


All versions of yii3-tenancy with dependencies

PHP Build Version
Package Version
Requires php Version 8.3 - 8.5
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/simple-cache Version ^3.0
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 rasuvaeff/yii3-tenancy contains the following files

Loading the files please wait ...