Skip to main content
Experimental. Everything on this page is marked @experimental in fapost/foundation 0.15: the declarations, their targets, the fapost-ui.json schema and the naming rules. Until a real Solution has exercised them they may change in a Foundation minor release, with an entry in its changelog — see Stability policy.
A Solution adds to the console in two halves. Its PHP declares what it adds, from its service provider. Its front end ships prebuilt — hashed ES modules and CSS in the package’s dist/ — and the browser loads them by name, running on the console’s own Vue, Inertia and kit. Nothing is compiled into Core, and installing a Solution needs no Node and no rebuild of Core.

How it fits together

  1. Your provider’s boot() declares an application, actions, widgets and so on through ConsoleExtensionsInterface. Core ties every declaration to your Solution’s id and closes the registry when the application has booted.
  2. platform:update checks your fapost-ui.json against those declarations and copies your built files to public/solutions/<id>/<hash>/.
  3. On every console request Core keeps only the declarations the request may see: your Solution is active for the tenant and its UI is published, the user has the declaration’s ability, and — for what lives on an assistant — an assistant is open. Labels are translated on the server. The rest never reaches the browser.
  4. The browser renders those points and, when one is shown, loads its component from your bundle. Pages are loaded the same way when one of your routes renders <id>::<Path>.
Hiding something in the browser is never the access check: every route of your Solution authorizes the request again on the server.

Registering

Require fapost/foundation >=0.15 <1.0 (>=0.17 <1.0 if the Solution also registers action handlers), override boot() in your provider, call parent::boot() first, then declare:
Declare from boot() (or from bootSolution(), which parent::boot() runs) and nowhere else: Core opens the console window for your Solution around boot(). A call from register(), from a booted() callback or from a request throws InvalidConsoleDeclarationException. So does a call from registerExtensions(): Core runs it earlier, before any Solution’s console window opens, so keep it for action handlers. The registry also throws when a name is outside your namespace, when you declare a second application, and when a key repeats within the same point and target. The DTOs check formats when they are constructed and throw InvalidArgumentException:

The six points

The targets are enums: a target Core does not list cannot be written. New targets arrive as new cases in a Foundation minor. Application. At most one per Solution, keyed by your Solution id, so a Solution whose id is console or admin cannot have one. entryRoute is where the rail opens it; menu lists MenuItems (label, route, icon, ability, an optional group heading) in display order. With perAssistant: true it lives on an assistant like the Console does, and is offered only where an assistant is open. Core’s own menus never receive your entries. Your application is not pinned to the rail by default; shortLabel defaults to label. Context action. ContextAction::link() navigates to one of your routes, and that route takes a record parameter: Core fills it with the id of the contact or conversation the action was chosen on. A link to a per-assistant route also gets the open assistant as {assistant}, and is left out where no assistant is open. Laravel passes route parameters by position, so the action of assistant/{assistant}/apps/<id>/contacts/{record} takes string $assistantKey, string $record. ContextAction::dialog() opens your component in the kit’s dialog instead. Shell element. Loaded only after the page has rendered, so it never slows a screen down. With perAssistant: true it is shown only where an assistant is open. Dashboard widget. WidgetSize::Single, Double or Full — one column, two columns or the whole row of the dashboard’s grid (two columns on the assistant console’s dashboard, three on the admin one). A widget fetches its own data from your routes; it gets nothing from Core’s dashboard request. Settings tab. A form of its own, with its own routes and storage; Core’s save button does not submit it. The tab is addressed as ?tab=<id>.<key>. On both settings screens a Solution’s tabs join Core’s tab bar after Core’s own tabs; while one is open, Core’s form and its save button are hidden. Table column. Core renders the cells; you supply only the values, through a class implementing ColumnValuesInterface:
It is resolved from the container and called once per table page, inside the tenant context, with the row ids of that page. One class may serve several columns, told apart by $context->key; $context->assistantId is the open assistant, if any. Return scalars or null keyed by row id; a missing id renders an empty cell.
values() runs synchronously inside Core’s request, once per page, and there is no timeout: PHP cannot interrupt it, so a slow one slows Core’s table. Keep it fast — one batched query for the page’s ids, no remote calls.
The cell type is CellType::Text, Badge, Number (formatted in the user’s locale), Date (shown relative, the exact value on hover) or Status with tones mapping a value to Tone::Neutral, Success, Warning, Danger or Info. A column cannot be sorted or searched, and a cell cannot be your own component, in this version.

Routes and pages

Register routes through the contract, never on your own. Core adds what you may not choose yourself: the console’s domain, the prefix, the names and the middleware. Both groups are the console’s own stack — session, tenant, signed-in active staff user — followed by a check that answers 404 while your Solution is not active for the tenant or its UI is not published. solution.assistant also resolves the assistant from {assistant}, as the Console’s routes do. When your application declares an ability, every route also requires it. The name you give a route is prefixed with solutions.<id>.: ->name('board') becomes solutions.showcase.board, which is the name your declarations use. Use controller actions, not closures, so the routes survive route:cache. Authorize every action with your own policies: the menu entry a user cannot see is still a URL they can type. A page is an Inertia response with a page of your own:
Rendering a page outside your namespace — Core’s or another Solution’s — from one of your routes is an error. Core wraps your page in the console’s shell unless the page sets its own layout, and marks your application as the current one in the rail.

Names

Pages and components are named <id>::<Path>: your Solution id, then PascalCase segments joined by /, such as showcase::Board/Index or showcase::Widgets/Stats. Core’s own pages have no namespace. Pages and components share one namespace, so a Path names exactly one file. Since names appear in URLs, asset paths and pins, the rule that a Solution’s id never changes protects them too.

Building the bundle

Build the bundle with FaPost’s Vite preset, @fapost/vite-plugin-solution, published to npm from version 0.1.0. Install it with Vite, the Vue plugin, and vue, @inertiajs/vue3 and @fapost/ui at the versions the Core you target ships, then name your pages and components in vite.config.js:
vite build writes the modules to dist/assets/ and dist/fapost-ui.json beside them, with your Solution id from extra.fapost.id in composer.json and the kit, vue and inertia ranges of the installed packages. It keeps the specifiers below external, and fails on an import of those packages the console does not map and on a file type publication would leave behind. The rest of this section is what the preset does for you, and what a bundle built another way must do. Build your front end into a directory of its own, such as dist/, with fapost-ui.json next to the files. Every page and component is an ES module whose default export is a Vue component. Keep these specifiers external — do not bundle them:
  • vue
  • @inertiajs/vue3
  • @fapost/ui and its public subpaths: @fapost/ui/components/alert-dialog, avatar, badge, button, card, checkbox, command, confirm-dialog, data-table, dialog, dropdown-menu, empty-state, form-field, form-section, input, label, localized-field, meter, options-picker, select, separator, sheet, skeleton, sonner, switch, table, tabs, textarea, tooltip, value-list-input, and @fapost/ui/lib/utils, @fapost/ui/lib/relative-time
The console’s import map points each of them at the copy the console itself runs, so there is one Vue, one Inertia router and one kit on the page. Every subpath resolves to the same module, so a named import works from any of them. The shell and the console’s live-updates module are not part of the public surface. Your own npm dependencies go into your bundle. Besides the components, the surface carries a few helpers: toast from @fapost/ui/components/sonner, ValueCell and the CellType and CellTone types from @fapost/ui/components/data-table, and interpolate (fills :name placeholders) from @fapost/ui/lib/utils. Show a toast with that toast, not with one from vue-sonner: the toasts live in one module, and only the console’s copy is connected to the toaster on the page.

fapost-ui.json

Files are relative to the directory of fapost-ui.json, made of letters, digits, ., _ and -, with no segment starting with .. Pages and components together list at least one entry. Any other field is an error. To check the file without Core, run Fapost\Foundation\Console\Bundle\UiBundleParser, which reports every violation at once. Point the manifest at it with extra.fapost.ui, a path relative to the package root that ends in .json:
Commit the built dist/ in the package, or build it before the package is installed: the image that runs Core has no Node.

Publication

php artisan platform:update checks the bundle of every installed Solution with extra.fapost.ui together with the manifests, before any migration, and --validate-only runs the same check. Each of these fails the command and changes nothing:
  • fapost-ui.json is missing, is not valid JSON, or breaks the schema;
  • a listed page, component or stylesheet does not exist inside its directory;
  • a component named in your PHP declarations is not listed under components;
  • fapost-ui.json sits at the package root rather than in a directory of its own;
  • a file in that directory has PHP anywhere in its name (x.php, x.php.js, x.phtml), since a web server may execute it;
  • a link leads outside that directory.
After the migrations the command copies the directory to public/solutions/<id>/<hash>/, where <hash> comes from the content of fapost-ui.json — your build’s hashed file names make every build a new directory, served as immutable. Only fapost-ui.json and files with these extensions are copied: js, mjs, css, map, woff, woff2, ttf, otf, png, jpg, jpeg, gif, webp, avif, ico No SVG (it can carry script), no HTML. Any other file is left behind with a warning, since a module that imports it would fail in the browser; a listed page, component or stylesheet that could not be copied is an error. Hidden paths, such as .git/ or .env, are skipped without a word. The current build and the one before it are kept, so a browser still holding the old page map can finish loading; older builds are removed. A Solution whose build changed since the last platform:update is not served until the command runs again, or until solutions:watch publishes it on a development machine (below). The console’s asset version includes the published bundles of the tenant’s active Solutions, so activating, deactivating or updating one reloads the page on the next visit. Publication writes to the public/ of the container that runs the command. A single-tree install — development, bare metal — serves it at once. The Docker Compose installation serves static files from its separate web image, so there the Solution goes into images built from the published ones: php artisan solutions:publish runs the same checks and publishes the bundle while the image is built, with no database, and the web image copies public/solutions/ from it.

Developing against a running Core

Install the Solution into a Core checkout from your own checkout with a path repository in the composer overlay, so vendor/ links to your working copy. Then run two watchers:
Every save rebuilds dist/ and rewrites fapost-ui.json. Releases of the preset after 0.1.1 write it after the modules it lists, so it never names a file that is not there yet. solutions:watch looks at the bundles every second (--interval=<seconds> to change it), and publishes a new build as platform:update would — the same checks, the same allow-list, the current build and the one before it kept — then rewrites the Solution cache. Core is not restarted or rebuilt: the next request serves the new build, and because the console’s asset version changed, the open page reloads on your next click or navigation. There is no hot module replacement. A build that does not hold up — still being written, or broken — is reported once and nothing is published for it; the next look tries again. Until a build that holds up is published, the Solution’s pages are unavailable, since the cache no longer matches the fapost-ui.json on disk. It polls rather than waiting for file events, so it works when your editor and Node run on the host and Core in a container. Your PHP is read once, when the command starts: after declaring a new component, stop it and run it again. When a Solution is installed or removed, or a composer.json changes, the command clears the Solution cache and stops; run it again. It never migrates anything and refuses to run in production, where platform:update publishes builds.

Trust and failures

Same origin means full trust. Your JavaScript runs with the signed-in user’s session: it can call any console endpoint as that user and read the screen it is mounted on. That adds no new trust — your PHP already runs with the application’s full rights, and installing a Solution is the decision of whoever builds the image. So authorization stays on the server, secrets stay out of props, and a component mounted on Core’s screens receives nothing but recordId and assistantId (where they apply). This holds only for code an operator installs; a Plugin ships no Vue. A failure stays yours. A component on Core’s screens whose name is not in the map, whose module does not load within ten seconds, or which throws while rendering is hidden, with the error in the browser console; the screen keeps working. A page that cannot load becomes a “Solution unavailable” page inside the shell rather than a blank screen. A column whose values() throws is left empty and the error is logged. A link action whose route does not exist is left out.

The boundary

One Vue instance and one kit are what let a prebuilt bundle work without a rebuild, and the server is the only place that knows activation, entitlements and permissions. Prefix your own CSS classes so they cannot collide with the kit’s.

Not ready yet

  • The preset’s first release. Until @fapost/vite-plugin-solution 0.1.0 is on npm, install it from a checkout of its repository next to your Solution (npm install --save-dev file:../vite-plugin-solution). The kit itself is published: install @fapost/ui to build and type-check against it.
  • The version check. kit, vue and inertia are compared with the versions the console ships (the syntax is in the table above). platform:update warns about a mismatch, and the Solutions page of the admin panel refuses to turn the Solution on and says why. A Solution that was already on when a Core upgrade made its range fail stays on — its flows, actions and data keep working, and it can be turned off — but its console UI is not served: its declarations and page map are left out, the app switcher marks its application as needing an update, and its routes answer 503 with a page saying so (a user its application’s ability does not let in still gets 404). A build that fits is served again after the next platform:update.
  • Activation. A tenant turns a Solution on from the Solutions page of the admin panel or with solutions:activate and solutions:deactivate; see Building a Solution.