Plugin package contract
This is the maintained developer contract for a Pulse plugin. Lifecycle and helpers, frontend/runtime packaging, data ownership and security explain its individual interfaces. Source validation and actual call sites determine current behavior; declarations in config/plugin_schema.php do not automatically enforce every property they describe.
Ownership rules
- Keep domain behavior in your package, with its own stable slug, namespace and owned table names.
- Core must remain usable without your package. Do not make core import concrete plugin classes.
- Do not add game-specific columns to core
users. Store owned records or use the metadata model. - Authenticate player APIs, scope owned records to the authenticated identity, and enforce roles/permissions/capabilities at the operation boundary. A menu or frontend route is not authorization.
- Preserve existing data deliberately across upgrades/disablement; destructive uninstall behavior needs explicit ownership and recovery rules.
- Treat installed PHP/JavaScript as trusted executable code. Hashes/signatures establish artifact integrity/identity, not a safe execution sandbox.
Identity and validation
PluginValidationService::validatePath(path,expectedSlug=null,checkFrontendFiles=true) reads plugin.json and returns valid,errors,warnings,manifest,path. It does not install/enable the package or prove its requests work.
| Field | Actual validator rule / meaning |
|---|---|
name, author |
Required strings, maximum 255 characters |
description |
Required string |
slug |
Required lowercase letters/digits with single hyphen separators; must match an expected slug when supplied |
version |
Required three numeric components, such as 1.2.0; this validator does not accept prerelease labels |
enabled, license_required |
Optional booleans; runtime activation later belongs to installed_plugins |
requires.laravel |
Optional string evaluated by the actual constraint resolver |
requires.plugins |
Optional dependency map; each required package must already be installed/enabled; version matching is applied only when its constraint is a string (nonstrings bypass that version check) |
settings, permissions, hooks, routes, frontend |
Optional arrays/objects; consumers impose further meaning |
settings.menu |
Optional object (enabled, section, order, parent, roles, label); the validator refuses true or a string. Rows registered from older scalar manifests still load with no label |
settings.menu.label |
Optional string, maximum 255 characters (or null). Names the plugin's player menu entry; when it is missing or blank the entry uses name, so a package called "Wreckage City Combat" can appear as "Combat". Non-English locales still translate the entry through destinations.names.<slug> |
namespace, class |
Namespace/class metadata for discovery; when a string class is declared the corresponding basename PHP file must exist |
Reserved slugs are enabled, slots, menus, permissions, status and admin, to protect the core registry routes; with the slug admin every api/plugins/admin/... route would match the plugin admin boundary and refuse players. Use consistent slug/class spelling and Linux-compatible case. Prefer an object for a dependency map ("plugins":{}) even though associative JSON decoding and the validator accept arrays.
Routes and code placement
Package directories normally contain the entry class, plugin.json, Controllers, Models, Services, routes, database/migrations, optional config.php, hooks.php, docs and frontend. Scaffolding commands describe the exact generator variants; there is no assumption all generators create the same tree.
Declared route switches require their corresponding files: routes.web → routes/web.php, routes.api → routes/api.php, routes.admin → routes/admin.php (admin-only), routes.moderator → routes/moderator.php (optional, admits moderators; default false), and routes.public_api → routes/public.php. The provider also checks file existence when loading; a manifest switch alone does not create a route. Plugin routing explains canonical prefixes, aliases and middleware.
Plugin PHP is trusted code with full application access: the plugin admin boundary (admin-only /admin paths, enforced at registration and again on every request) protects against misconfiguration and accidental exposure. It does not stop a deliberately malicious plugin; package signing and review must stop that.
The base Plugin's register, boot, install, enable, disable, uninstall and upgrade methods have different callers/timing. They are not an automatic linear sequence on every request. Use the actual lifecycle table and test your installation path.
Frontend descriptor
Each frontend route has string path,name,component; component keys must exactly match the built bundle registration. frontend.slots maps slot names to arrays of string component keys. A declaration does not render or authorize anything until its host loads and consumes it.
Packages with frontend routes/slots require a validated precompiled frontend.runtime descriptor: format lfstudio-runtime-v1, plugin-relative JavaScript entry, SHA-384 integrity, and optional styles with path,integrity. Assets must exist, match their hashes and pass path/size checks. Runtime asset publication explains versioned public URLs and cache/update behavior.
Use the actual Vite builder for Vue functionality (npm --prefix frontend run plugin:build -- <slug>). pulse:package packages that existing build and refuses the scaffold's placeholder bundle. A successful ZIP export alone proves neither browser rendering nor a signed marketplace release.
Hooks, settings and data
Only hooks with actual dispatchers run automatically. Individual hooks distinguish those from catalogue names. user.created receives ['user'=>$user]; it is not the User directly. Your own custom hook needs an explicit caller and payload contract.
Current core User does not apply HasPluginMetadata. Use static PluginMetadata methods with an existing owner, or deliberately apply the trait to a model you own. User metadata limits explains the supported calls. Metadata helpers do not supply account authorization or atomic reward accounting.
Base Plugin manifest config(), Laravel config('plugins.<slug>...'), database settings and admin schema are separate systems. The existing singular/plural settings-prefix difference is documented in plugin settings APIs; do not assume a rendered admin control is read by your runtime helper.
Shared image fields and optional providers
Declare an image picker in a trusted GameEntityStudioService::registerSchema() resource's fields descriptor. The value remains a string in the package's existing column; align max with that column:
'image' => [
'label' => 'Item image',
'type' => 'image',
'nullable' => true,
'max' => 255,
'library' => [
'plugin' => 'image-library',
'base_url' => '/api/plugins/image-library/admin',
],
],
The shared administrator field opens the provider's picker and writes its selected public asset URL into the draft. Clearing the field writes null. Existing external image strings can remain legacy previews; the picker does not download them to the server. Image fields receive bounded string validation in Studio; the provider owns raster upload validation, managed-file storage and reference checks. An image descriptor does not grant upload permission or make a public asset private.
The provider is optional unless your package declares it in requires.plugins. When it is unavailable or disabled, the picker reports that state. Studio rejects a changed image value when its declared provider is disabled or absent, while allowing other edits that preserve the image value. Existing values stay readable. Test the absent, disabled and enabled cases rather than importing the provider's PHP classes into core. Provider API limits, file ownership, capability checks and lifecycle behavior belong to the canonical Image Library package documentation.
Studio dispatches admin.content.saved inside the content mutation's database transaction. A provider uses this action to synchronize exact managed references for declared fields. HookService::actionStrict() runs listeners synchronously in descending priority order and propagates their exceptions; it bypasses the normal action's failure circuit and exception swallowing. It does not create a transaction itself. A failed required listener therefore rolls back Studio's content, audit and reference writes on the same connection. No listeners means no additional invariant is supplied; a hook name alone is not an installed provider.
Keep strict listeners limited to transactional work. Filesystem deletion, HTTP requests and other external side effects cannot be rolled back with the database; arrange suitable after-commit handling or an outbox in the owning service. See the hook payload and failure contract before implementing a listener.
Verify a release
Validate the manifest/dependencies/assets, exercise real authorized and forbidden requests, run migration and upgrade checks with existing data, check enable/disable behavior and inspect the actual host-rendered interface. Use testing and the complete teaching example for concrete patterns.
Source: PluginValidationService, base Plugin, provider, runtime assets and schema declarations.