Skip to main content
A Solution is a vertical product module — HR, recruitment, anything with its own domain behaviour — distributed as a Composer package under your own vendor.
The external Solution lifecycle is partly built in Core. The manifest below is read and validated by platform:update today, and a tenant’s activation of a Solution is stored and switched with solutions:activate and solutions:deactivate or from the Solutions page of the admin panel. Core also registers the action handlers a Solution declares and refuses them for a tenant that has not activated it. The other registrar methods and the release tooling around them are still being built. Treat this page as the contract you will be held to, not as a finished walkthrough.
To see the whole path working before you write your own, start from fapost-lab/solution-hello-world: the smallest Solution that installs with a composer overlay, registers one action for the call node and adds one page to the console from a prebuilt bundle, with tests and CI that run it inside Core.

Boundaries

A Solution must not live under app/Solutions inside Core. It is an external package, resolved through Composer like any other dependency — see Development setup for the two-lane workflow. Its public contracts belong in fapost/foundation. Primitives with no Core dependency belong in fapost/support. Neither package may reference App\…, and neither may absorb business logic that belongs to Core. Screens in the console go through the console UI contract: the Solution declares them in PHP and ships its front end prebuilt, loaded at run time on the console’s own Vue and kit. A Solution cannot drop Vue files into Core’s source tree — Core’s front end is compiled ahead of time.

The manifest

A Solution describes itself in its own composer.json: "type": "fapost-solution" and an extra.fapost block. It is data, so Core can check it without loading your code, and the check fails on the deploy, not on a customer’s request.
The version is the package version Composer already knows, and the Foundation range is the package’s require; neither is repeated in the manifest. solution and solutions are reserved from fapost/foundation 0.14; use neither, whatever version you build against, because Core’s own tables carry that prefix. contact and call are reserved from 0.36: they are names of the platform’s state namespaces, and a Solution’s id is also the name of its own. The id never changes. Plans, activations, action ids, permissions and limits all hang on it. A different id is a different Solution, and moving a customer’s data across is your job. List your actions. The prefix <id>. keeps your handlers from colliding with another Solution’s, or with core.* and platform.*. Declaring them lets Core show what your Solution offers without loading it. Do not use extra.laravel.providers. Core boots the provider named in the manifest itself, and only for a Solution whose manifest is valid; Laravel’s package discovery would boot any provider listed there regardless. Any entry is a manifest violation (extra.laravel.providers: a Solution's provider is booted by Core; remove this block); an empty list is accepted.

Activation

Installing a Solution does not turn it on. Activation belongs to a tenant and is stored in that tenant’s own schema, so it goes with the tenant’s backup and is removed with the tenant.
  • A Solution is off by default for every tenant, new or existing, until it is activated.
  • It counts as active only while it is installed in the image with a valid manifest and either the operator grants it to the tenant (a plan’s bundle or a running add-on: it is on with nothing stored, and the tenant cannot turn it off) or the tenant has it activated and the operator allows it. Without an operator package every Solution is allowed and nothing is granted — see Solution entitlement. Remove the package, break its manifest or lose the grant or the entitlement, and it is inactive; bring it back and it is active again. Nothing is written in between, and your Solution learns of it only as solution_inactive, or as solution_not_ready while the tenant’s tables are still being prepared (see Tenant migrations).
  • Do not rely on the moment of activation. A grant turns a Solution on and off with no call into your code, and Core does not call onActivate() or onDeactivate(). Create your tables with the migrations declared in the manifest: Core applies them in a tenant’s schema when the Solution starts running there (activation, or the first use of a granted Solution) and keeps them current on upgrade where it is on or already has them. Initialise anything else lazily and idempotently on first use.
  • Deactivating never touches the Solution’s data. The activation record stays, and every change is journalled with who made it, when, and why.
  • A change is seen by the next request or job of any process; a job already running keeps the answer it was given at its first question.
An operator switches it with solutions:activate and solutions:deactivate, each with a required --tenant=<slug>; see the command reference. A staff user with the right to manage settings does the same from the Solutions page of the admin panel, which also lists what your Solution registers and why its console interface does not fit and it cannot be turned on; see Solutions. The journal records that user as the actor.

Checking it

Prints every problem, not just the first, and exits with code 1:
A package with a wrong manifest, and both packages when two share an id, are left out of the catalog. The same check runs at the start of every platform:update, before any migration. See Upgrading and rollback. Without Core, for example in your package’s own CI, run the same rules from fapost/foundation:

How the format changes

Unknown fields are an error, except x-*, so a Solution written for a newer platform never installs quietly without part of its behaviour. A new optional field arrives in a minor release of fapost/foundation; to use it, require that version, and Composer then refuses to install your Solution on a platform that does not have it. A breaking change gets a new schema number; Foundation reads the current schema and the previous one within one major version, and refuses anything else. A field not in schema 1 yet is added the same way when its contract is settled, as ui was in 0.15 and migrations in 0.38.

Tenant migrations

A Solution that stores data creates its tables with migrations declared in the manifest:
The value is a directory relative to the package root. It needs fapost/foundation ^0.38, and Core checks that it exists inside the package. Each file returns an anonymous class extending Illuminate\Database\Migrations\Migration and names no connection:
Files run in name order, and only up() is called: there is no down() and nothing is rolled back. Each file runs once per tenant, whatever its name: a file added in a later version that sorts before ones already applied still runs. When they run, in a tenant’s own schema:
  • On activation. The migrations run before the activation is stored. If one fails, the activation is refused and nothing is stored: the console says the Solution’s data could not be set up, the cause goes to the application log, and solutions:activate prints it.
  • On the first use of a granted Solution. A Solution the operator grants has no activation moment. Until its tables are prepared, a step or call answers solution_not_ready, console pages show that the Solution is preparing, and a queued job prepares the schema.
  • On upgrade. platform:update brings current the tenants where the Solution’s tables already exist (deactivated Solutions included) and those that turned it on themselves, even before it had migrations. It does not touch the others: a Solution only granted, with no tables yet, is prepared on its first use.
  • At once. solutions:migrate --tenant=<slug> prepares a tenant’s Solutions immediately; see the command reference.
Rules
  • Expand only. Add tables named <id>_..., columns and indexes. Never drop, rename or change the type of anything: older code may still run against the new schema, and nothing is rolled back.
  • One transaction. Everything of one Solution in one tenant runs in a single transaction, so do not use CREATE INDEX CONCURRENTLY or any other statement that cannot run in a transaction. A failure leaves that tenant’s schema unchanged.
  • Never loadMigrationsFrom(). It would run your migrations on the landlord, so platform:update refuses it and exits with code 1 before anything is migrated.
  • Deactivation keeps the tables.

Background jobs

Experimental. It needs fapost/foundation ^0.39, and the contract may still change.
A Solution queues background work as a SolutionJob. Extend Fapost\Foundation\Solution\Queue\SolutionJob, return your Solution’s id from solution() and do the work in perform():
Dispatch it through Fapost\Foundation\Solution\Queue\SolutionQueueInterface, which you inject where you need it, for example into an action handler:
Never call dispatch() on the job itself or use Laravel’s dispatcher: such a job has no tenant, and it fails (and is retried until its tries run out) when it runs. What Core does
  • It runs the job in the tenant that queued it, so perform() sees that tenant’s schema.
  • Your jobs go to a queue of their own, solution-jobs.<id>, so another Solution’s backlog does not hold them back.
  • tries and timeout are yours to set (defaults 3 and 300 seconds).
  • handle() and middleware() are final: Core’s gate around the job cannot be replaced or extended.
  • The job is serialized before the tenant is known, so do not do work in __wakeup(), __unserialize() or a constructor-time read of the database: it would run outside any tenant.
Refused at dispatch. dispatch() throws SolutionJobRejectedException and queues nothing when:
  • no tenant is current;
  • the job’s class is not in your Solution’s package;
  • a property is not null, a scalar, a backed enum or an array of those, private properties of your own base classes included. Pass ids and load models in perform();
  • the timeout is below 1 or above 1500 seconds;
  • the class or a parent carries one of Laravel’s queue attributes (#[Timeout], #[Queue], #[Delay]…), defines a queue() method or a middleware property: Core decides the queue, the connection and the gate;
  • the job implements ShouldBeUnique: not supported for Solution jobs yet.
Decided when the job runs
  • The tenant no longer exists: the job is dropped.
  • The tenant is stopped: the job is retried an hour later, for as long as the tenant stays stopped.
  • Your Solution is turned off for the tenant: the job is dropped.
  • The Solution’s tables are not ready yet: the job is retried a minute later. This does not spend an attempt, and the job is dropped, with a warning in the log, after 48 such postponements.
Every drop and postponement is written to the application log. Chains and batches are not supported.

Registering actions

A Solution gives flows something to do by registering action handlers, which the call node reaches with the handler transport. An action is the right shape for one step with parameters and an outcome; a step that needs its own form, branches or state is a node type. Implement Fapost\Foundation\Action\ActionHandlerInterface, declare the id in the manifest and register the class from your provider:
Core calls registerExtensions() once per process, with a registrar of your own, after every provider’s register() and before any boot(). So it runs before your bootSolution() and before the registries close. The provider never fetches a registrar itself. Registration is strict and fails the boot. The process does not start (so platform:update fails on the deploy, not at a customer), and the message names the Solution, the package, the action and the class, when:
  • the action id is not listed in extra.fapost.actions;
  • the id is already registered (two handlers, or a Solution and Core);
  • the class does not implement ActionHandlerInterface;
  • you call registerDataAccessor(), registerRagAdapter(), registerRoutes(), registerSchedule() or registerMigrations(), which Core does not support for a Solution yet. Migrations are declared in the manifest instead; see Tenant migrations.
The opposite case, an action listed in the manifest that no handler registers, is reported by platform:update (also with --validate-only) as acme/fapost-feedback: extra.fapost.actions[1]: "feedback.score" is declared but not registered, and exits with code 1 before anything is migrated. A handler is built on every call, in the job that makes it, so its constructor may take scoped services (the current tenant, a connection) and gets the ones of that job. Nothing is kept between calls. Core also builds one throwaway instance at boot to read id(), outside any tenant, so keep the constructor cheap and do the work, and every read of tenant data, in handle(). What the handler is called with. handle(array $parameters, CallContext $context) runs inside the job of a tenant that has the Solution activated; $context->tenantId is that tenant. The builder’s Test call reaches the same handler for the same tenant, with a synthetic context (contactId test-contact, sessionId test-session), and it really runs: a handler must cope with a contact that does not exist. In a flow started by a schedule, a webhook, an API call or a Core event there is no contact at all: $context->contactId is null. Activation is checked on every call. The action of a Solution the tenant has not activated, or has just deactivated, is refused: the call node takes its error handle with error_code = solution_inactive, the flow log shows solution_inactive: <solution id> on the block, and your handler is not built or called. While the tenant’s tables for an active Solution are still being prepared, the call is refused the same way with error_code = solution_not_ready (the log shows solution_not_ready: <solution id>); the preparation is queued automatically. A session that is running when a Solution is deactivated is not failed: its next call to that Solution takes the error handle. The builder lists the actions of Core and of the tenant’s active Solutions only; a flow that already uses an action of a Solution that is off still opens and shows the saved value. A refused call still counts as one call execution, as any refusal does. Outbound HTTP. Core’s egress check covers only its own http transport. A handler that makes a request from a flow parameter must itself refuse private, loopback, link-local and cloud-metadata addresses after resolving the name and on every redirect hop. A shared contract for this will arrive with the first Solution that needs outbound HTTP. onActivate() and onDeactivate() are not called yet.

Registering node types

A Solution can add its own blocks to the flow builder. A node type is a node handler whose type() starts with your id and a dot (feedback.collect), so it can collide neither with Core’s types, which never contain a dot, nor with another Solution’s. Declare every type in extra.fapost.nodes and register its handler from the same registerExtensions() as your actions:
Where it appears in the palette. category() decides the group: a value of Fapost\Foundation\Flow\Enums\NodeCategory (Conversation, Logic, Data, Contact, Integration, AI) puts the node into that group of Core, and your Solution’s id puts it into a group of its own, labelled with your manifest name. Anything else fails the boot. Versions. A node type is versioned like Core’s: the engine resolves type@version, a saved node keeps its version forever, and a breaking change is a new version registered beside the old one, which stays registered — see Versioning. Registration fails the boot, as for actions, when the type is not listed in extra.fapost.nodes, is already registered, does not start with your id, the class does not implement NodeHandlerInterface, or category() is neither a NodeCategory value nor your id. A type listed in the manifest that no handler registers is reported by platform:update and exits with code 1. Activation is checked on every step. A node of a Solution the tenant has not activated is not run: the engine does not build your handler, the node takes its error handle, and the flow log shows solution_inactive: <solution id>. While the tenant’s tables are being prepared it takes the same handle with solution_not_ready: <solution id>; the preparation is queued automatically. A node whose Solution is no longer installed takes the same handle with solution_not_installed: <solution id>; when the installed Solution no longer ships the version the node was saved with, it is solution_version_missing: <solution id>. So give every node an error handle; publishing warns when it is not connected, and without an edge the session simply ends there. The builder offers your nodes only to tenants that have the Solution on; a flow that already holds them still opens, shows them greyed out with the reason, and keeps their settings. Publishing does not check activation. Validating a node. Beyond the required fields of configSchema(), a handler may also implement Fapost\Foundation\Flow\Contracts\NodeConfigValidatorInterface. Core calls validate() when it validates a flow for publishing and shows each NodeConfigIssue: an error blocks the publish, a warning does not. Keep it pure — no queries, no requests. The builder shows your issue’s message as you wrote it, in every admin language, so translate it yourself if your Solution ships translations; Core translates only the issues of its own nodes, by code, from the values in NodeConfigIssue::$params.

Registering trigger types

Experimental since fapost/foundation 0.46: the contract may still change in a minor release.
A Solution can also add its own kind of trigger next to Core’s message, schedule, webhook, API and event triggers: “feedback submitted”, “order paid”. A trigger type implements Fapost\Foundation\Flow\Contracts\TriggerTypeInterface, its type() starts with your id and a dot, and you declare it in extra.fapost.triggers and register it from registerExtensions():
Every method must be pure — no queries, no requests — and the constructor cheap: Core builds the class whenever it asks it something. Starting runs. Your own code — an action, a node, a background job — starts the flows that listen to your type with Fapost\Foundation\Flow\Contracts\TriggerFirerInterface, taken as a constructor dependency:
Core queues the fan-out after your database transaction commits and returns at once. For every active trigger of the type in that tenant whose config matches() the payload, it starts one run, once per fire key: firing the same key again starts no second run while the first one is kept (run retention), so retrying your call is safe. The run has no contact, so the flow may hold no node that needs one; it reads the payload as flow.trigger.* and the type as flow.trigger_type. Nothing starts while your Solution is off for the tenant. The payload is JSON of at most 64 KB; an unregistered type, an empty fire key or a payload that does not fit throws InvalidArgumentException at your call. A fire raised while a flow runs — from your action or node in that run — counts towards the same chain limit as events (five links), past which nothing starts. A fire from your own queued job starts a new chain: if a flow on your trigger calls an action that leads your job to fire the same type again, breaking that loop is up to you. In the builder and at publish. The builder lists your types for tenants that have the Solution on and draws their form from configSchema(); a saved trigger of a Solution that is off or removed stays greyed out with its settings. Publishing a flow with your trigger needs the Manage automations permission, like every trigger but a message one. It is refused with trigger_type_not_installed when your Solution is not installed, and only warned about (trigger_type_solution_inactive) when it is installed but off for the tenant.

Your state namespace

With "state": true in the manifest your Solution owns one more top-level state namespace, named by its id: feedback.*. Only your own node types may write it, through stateChanges; anyone may read it in templates and conditions. Your actions do not write it: what an action returns reaches the flow through the call node’s mapping, into flow.* or call.*. Values a session already holds stay there when the Solution is turned off.

What a Solution typically contains

Most Solutions are a combination of pieces documented elsewhere in this section:

Action handlers

So flows can act on your domain.

A data accessor

So conditions can read your data without duplicating it.

Node types

Blocks of your own in the builder, with their own form, branches and state.

Builder configuration

So your nodes can be configured on the canvas.

Console UI

So staff work with your domain in its own application and on Core’s screens.

Migrations

Subject to the same migration isolation rules as Core.

Limiting what a tenant can create

If your Solution has records an operator should be able to cap per tenant (for example candidates), register a limit key from your service provider’s boot(). Core binds the registry in its own provider, which can run after a package’s register(), and closes the registry once the application has booted, so do not register from register() or from a booted() callback:
The key is snake_case and stable, because plans store limits under it; the label and unit are in English. An operator package reads the registry to offer the limit in its plan form, and answers how much each tenant may have through TenantLimitsInterface. Registering the key is the Solution’s whole contribution to the contract: it does not decide the number. Registering the key makes the limit exist; enforcing it is your Solution’s job. Create the records through one service that counts the tenant’s existing ones and asks RecordQuotaInterface before saving, and send every creation path through that service:
It throws RecordLimitReachedException with a message fit for the person who sees it; catch it where you show errors. It works in the tenant context of the current request or job. Records that already exist stay when a limit drops: only creating more is refused. See Foundation contracts for the interfaces.

Limiting how much a tenant does in a period

For work that is counted over time rather than stored, such as messages sent or calls made, register the key from boot() the same way with kind: LimitKind::PerPeriod. Nothing is stored in a tenant schema; the operator package counts. Spend one unit before the work, with a natural key that is the same on every retry, and do the work only when the answer is allowed:
Core wraps this call to fail open when the operator’s implementation throws; your code is calling the interface directly, so catch Throwable around it, report it and let the work through, which is what Core does. Build the UsageUnit before anything irreversible, and never put a personal identifier in the unit key. See Foundation contracts for what the implementation promises.

Before you start

Read Choosing an extension type first. The most common mistake is building a Solution for something that has no domain of its own and should have been a Plugin — or, more expensively, building one for something that belongs in Core.