Skip to content

Installation and Tenant ​

An installation answers three questions, each with one row in sdk_partners:

  • Whose platform is this? Pragmatiqu IT's — the platform owner.
  • Who runs it? The operator.
  • For whom does it run? The tenant.

The SDK needs all three. Without them it cannot say in whose name automation writes, whose name the shell shows, or who may open the first door. Tenant isolation — keeping one customer's data away from another's — is not the SDK's job: one database is one tenant, and the database boundary belongs to the deployment.

The SDK is a package you install to build an enterprise app on Laravel. Platform is the operational layer (a database per tenant routed by domain, customer onboarding, backup and restore) that turns it into a vertical SaaS, and we build it with you.

Two cases ​

In-house. A company runs its own app. Operator and tenant are one row.

Agency. An agency runs the app for a customer. The agency is the operator, the customer is the tenant: two rows.

The relationship operator_for connects them — from the operator to the tenant, in-house from the row to itself.

The installation: app/Installation.php ​

What is identical in every environment of an installation is a class with constants, generated by ui5:intake and committed with your code:

php
namespace App;

use LaravelUi5\Sdk\Installation\AbstractInstallation;

final class Installation extends AbstractInstallation
{
    public const string OPERATOR_KEY = 'ACME';
    public const string COUNTRY_CODE = 'AT';
    public const string BASE_CURRENCY = 'EUR';
    public const string TIMEZONE = 'Europe/Vienna';
    public const int PRICE_DECIMALS = 2;
    public const int PERCENTAGE_DECIMALS = 2;
}

OPERATOR_KEY is the operator row's ext_ref. The other five are the installation's values — the market's country, the base currency, the company's time zone, the decimal places of prices and percentages. The SDK reads only the operator key; the layers above it read the rest.

Inject LaravelUi5\Sdk\Installation\Contracts\InstallationInterface where you need the values; the SDK binds App\Installation to it. Its getters are final and fail loudly when a constant is missing.

The three rows ​

RowLevelWritten by
Pragmatiqu IT GmbH (ext_ref PRAGMATIQU), with its department Support@Pragmatiqu (PRAGMATIQU_SUPPORT)PlatformOwnerui5:intake, then every ui5:sync
The operator (App\Installation::OPERATOR_KEY)OperatorAdminui5:intake
The tenant — in-house the operator's own rowTenantAdmin for a new organisationui5:tenant

The platform owner's rows carry key, name and e-mail, no legal data. Support@Pragmatiqu is the door for support and is closed by default: no person, no login. Only the operator opens it, by creating a person who acts for the department, a login and a time-bound role assignment in the Partners app; closing it is the end of that assignment. The department is also the default automation actor.

A new database, step by step ​

bash
php artisan migrate
php artisan ui5:intake --name="ACME Inc." [email protected]
# check app/Installation.php, adjust its values, commit it
php artisan ui5:sync
FIRST_CHAIR_PASSWORD='…' php artisan ui5:tenant --operator \
  [email protected] --admin-name=Berger --admin-first-name=Alice \
  --password-env=FIRST_CHAIR_PASSWORD

Every database of an installation — development, test, production — is built by the same commands. None of them refuses to run in production.

ui5:intake: the operator ​

ui5:intake writes Pragmatiqu IT and Support@Pragmatiqu first, then the operator — an organisation on OperatorAdmin, exactly one per host.

OptionHolds
--namerequired — the operator's legal name
--emailrequired — its e-mail, the key the command matches on
--ext-refthe operator key; ignored when app/Installation.php exists — the class wins
--search-terma short search term; derived from the name when omitted
--vat, --office, --language, --phone, --foundedthe VAT number, registered office, language, phone, foundation date
--forceskips the "update in place?" confirmation

The operator key comes from App\Installation when the class exists, so every environment carries the same key however the name is typed; otherwise from --ext-ref, otherwise it is derived from the name. When app/Installation.php is missing, the command writes it with that key and the values AT, EUR, Europe/Vienna, 2, 2 — check them before the first sync. An existing file is never overwritten.

The command invents nothing: anything you omit is asked for interactively and otherwise left unset. It is idempotent, keyed on the e-mail. An operator under a different e-mail is refused.

ui5:sync: the platform owner and the check ​

Among its workers, ui5:sync checks that the operator App\Installation names exists on OperatorAdmin and stops otherwise, naming ui5:intake. Then it writes Pragmatiqu IT and Support@Pragmatiqu as the SDK declares them — name, e-mail, type, level, search term and the archive flag are set back on every run; addresses, phones and profiles you add stay — and links the department to its organisation with a primary owns.

ui5:tenant: the tenant and the first chair ​

ui5:tenant runs once per database, after the first sync. It writes what nobody who could sign in can write yet:

  • The tenant, named exactly one way: --operator (in-house — the operator is its own tenant), --tenant=EXT_REF (an organisation that already exists; its level stays as it is), or --name="…" (a new organisation on TenantAdmin, with --ext-ref and --email).
  • operator_for from the operator to the tenant.
  • The first chair: one person on OperatorAdmin who acts for the operator (acts_for, primary), with a login and the roles operator_admin, tenant_admin, local_admin and user. --admin-email (the login), --admin-name, --admin-first-name; the password comes from the environment variable --password-env names, never from the command line.

The links and the role assignments are granted by the platform owner. Everyone else is seated by the first chair in the Partners app.

It refuses before ui5:intake, before the first ui5:sync, when the operator already has a tenant, when the admin's e-mail belongs to a partner already, and when the password variable is empty.

The tenant at runtime ​

The tenant carries only its identity — enough for the shell:

php
namespace LaravelUi5\Sdk\Installation\Contracts;

interface TenantInterface
{
    public function getId(): int;        // the organisation row's id, local to this database
    public function getExtRef(): string; // its key across databases
    public function getName(): string;
    public function getLogo(): string;   // avatar_path, storage-relative
}

The SDK binds TenantResolverInterface to DefaultTenantResolver. It reads the row whose ext_ref is App\Installation::OPERATOR_KEY, follows its valid operator_for and wraps the organisation it points to in a Tenant. None or several fail loudly with MissingTenantResolverException, naming ui5:tenant. DefaultTenantResolver::partner() returns the row itself, for a layer that wraps it in its own tenant type.

SdkContext::tenant() resolves the tenant when it is first read and keeps it for the request. A run that never reads it — ui5:sync before ui5:tenant — needs none.

A host that finds its tenant another way rebinds the resolver:

php
// AppServiceProvider::register()
$this->app->singleton(
    \LaravelUi5\Sdk\Installation\Contracts\TenantResolverInterface::class,
    \App\Tenancy\MyTenantResolver::class,
);

In a multi-tenant deployment the host switches the database by domain before the resolver runs; the resolver then reads the tenant from the database the request is already connected to.

Tenant ≠ the actor's organisations ​

SdkContext distinguishes two organisation-shaped things:

  • tenant(): the company the installation runs for.
  • orgPartners(): the organisations the signed-in person stands for — as an employee (employed_by) or by commission (acts_for).

They coincide when a company runs its own app. They diverge when the agency's person signs in to the customer's installation.

Invariants ​

  • One tenant per database, never a query dimension. The SDK adds no tenant_id column. The tenant is found within the database, never selected across databases.
  • The resolver is the only seam. The SDK depends on TenantInterface and TenantResolverInterface; a host resolver may couple to whatever it needs.
  • Branding does not come from the tenant yet. The shell's sidebar name and logo come from a candidate chain — The logo and the name beside it shows how.

See also ​

  • Partners: system levels, memberships, relationship types
  • The First Seed: demo and training data after ui5:tenant
  • Configuration: the SDK's settings, the automation actor among them