Skip to content

Extension Lifecycle

Use this when a package should be discovered, audited, installed, enabled, and surfaced by Capell without patching host package code.

The lifecycle has four parts:

  1. Composer makes the package classes available.
  2. capell.json describes the extension contract.
  3. Install providers and commands prepare database/config state.
  4. Runtime/admin/frontend providers load only when the extension is enabled.

Uninstalling an extension also removes any published schema migration files that match files in the extension’s database/migrations directory. To run that cleanup directly, use php artisan capell:delete-migrations vendor/example, or php artisan capell:delete-migrations --all for every registered Capell package.

packages/example
├── composer.json
├── capell.json
├── src/Providers/ExampleInstallServiceProvider.php
├── src/Providers/ExampleServiceProvider.php
└── tests

Add admin, frontend, migrations, settings, translations, and docs only when the package needs them.

Composer discovery should make provider classes available. Capell decides when each provider bucket is loaded.

{
"name": "vendor/example",
"type": "library",
"autoload": {
"psr-4": {
"Vendor\\Example\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"Vendor\\Example\\Providers\\ExampleMetadataServiceProvider"
]
}
}
}

Keep the Composer-discovered provider safe. It can publish metadata, but it should not register runtime behaviour that depends on the extension being enabled.

capell.json uses manifest version 3. The validator rejects v1/v2 fields such as capell-version.

{
"manifest-version": 3,
"name": "vendor/example",
"slug": "example",
"displayName": "Example",
"kind": "package",
"visibility": "catalogue",
"capellApiVersion": "^1.0",
"version": "1.0.0",
"description": "Example extension for Capell.",
"product": {
"group": "Capell Foundation",
"tier": "free"
},
"namespace": "Vendor\\Example\\",
"surfaces": ["admin", "frontend", "console"],
"dependencies": {
"requires": ["capell-app/core"],
"supports": ["capell-app/admin", "capell-app/frontend"],
"conflicts": []
},
"providers": {
"metadata": [
"Vendor\\Example\\Providers\\ExampleMetadataServiceProvider"
],
"install": [
"Vendor\\Example\\Providers\\ExampleInstallServiceProvider"
],
"runtime": ["Vendor\\Example\\Providers\\ExampleServiceProvider"],
"admin": ["Vendor\\Example\\Providers\\ExampleAdminServiceProvider"],
"frontend": [
"Vendor\\Example\\Providers\\ExampleFrontendServiceProvider"
]
},
"contributes": [],
"contributionTraceability": {},
"database": {
"migrations": true,
"settings": false,
"requiredTables": []
},
"commands": {
"install": "capell:example-install",
"setup": null,
"setupParams": [],
"demo": null,
"demoParams": [],
"health": null
},
"settings": [],
"permissions": [],
"capabilities": [],
"performance": {
"frontendRenderBudgetMs": 50,
"adminQueryBudget": 25,
"cacheTags": [],
"cacheSafety": {
"cacheable": false,
"sensitiveOutput": false,
"queueInvalidation": false,
"variesBy": [],
"invalidationSources": []
}
},
"healthChecks": [],
"commercial": {
"privateDocsRequested": false
},
"marketplace": {
"summary": "Adds an example extension surface.",
"categories": ["example"],
"screenshots": []
}
}

visibility defaults to catalogue. Set it to support for dependency-only packages such as theme admin/core helpers. Support packages are hidden from normal package selection, but they remain installable when a visible package lists them in dependencies.supports.

Provider buckets must all exist, even when some lists are empty. Provider classes must be inside the package PSR-4 namespace and must extend Laravel’s ServiceProvider.

BucketLoads whenAllowed work
metadataThe package is discoveredSafe metadata only. Do not register runtime routes, resources, views, or listeners here.
installInstaller or extension install workflow runsInstall commands, migration publishing, setup helpers, one-off checks.
runtimeExtension is enabledShared runtime services, models, policies, events, package config.
adminExtension is enabled and admin/console runtime is activeFilament resources, admin bridges, widgets, settings schemas, admin routes.
frontendExtension is enabled and frontend runtime is activeRender hooks, frontend components, frontend routes, Tailwind assets, cache dependencies.

The separation matters. Admin code should not load on public frontend requests, and install-only wiring should not stay active after setup.

Use contributes when a package exposes contract-backed capabilities that Capell can audit.

{
"type": "admin-resource",
"class": "Vendor\\Example\\Extensions\\ExampleAdminResourceContribution"
}

Each contribution class must implement the contract expected by its type. Current contribution types include:

  • admin-resource
  • admin-page
  • admin-action-extender
  • section
  • page-type
  • page-variation
  • dashboard-widget
  • builder-block
  • overview-stat
  • schema-extender
  • configurator
  • model
  • permission
  • route
  • setting
  • frontend-component
  • render-hook
  • asset
  • migration
  • scheduled-job
  • console-command
  • agent-capability
  • health-check
  • workflow-attention

Use existing package extension points directly when the package only needs a small local hook. Use manifest contributions when the package should be auditable by Capell tooling.

Run the audit before wiring a package into an app:

Terminal window
php artisan capell:extension-audit packages/example
php artisan capell:extension-audit packages/example/capell.json

The audit checks the manifest shape, provider buckets, class namespaces, contribution contracts, cache-safety metadata, health checks, and Marketplace metadata.

Once Composer has installed the package:

Terminal window
php artisan capell:package-cache:clear
php artisan capell:package-cache
php artisan capell:extension-install vendor/example --dry-run
php artisan capell:extension-install vendor/example

Use --dry-run first on a new package. Use package-scoped params when the extension declares install parameters:

Terminal window
php artisan capell:extension-install vendor/example \
--url=https://example.test \
--languages=en \
--sites=Main \
--param=vendor/example:seedDemo=true

Before Capell installs or enables a non-foundation extension, it checks the installed Composer metadata and capell.json without loading the declared classes. It checks identity, manifest structure, autoload paths and declared class files, and refuses Composer plugins by default. When a caller supplies an expected version, previous version, slug or distribution checksum, it also checks those values. A supplied release checksum is compared with Composer’s recorded dist.shasum, which Composer verified against downloaded archive bytes. It does not detect post-install changes; source installs lack this digest and fail when a checksum is required, so strict checksum verification requires dist archives. A checksum for a different release is reported as a warning and is not compared. These checks reduce accidental or unexpected package activation; they do not establish that package code is safe. Composer may already have executed code before this check.

Marketplace releases may also supply release_content_sha256 for the release named by release_checksum_version. After the distribution checksum gate passes, Capell compares this value with the installed package directory. Omit it for releases that do not publish a content hash. A hash for another version is reported as a warning and is not compared. Generate the value from the exact release tree using php artisan capell:extensions:hash <path>.

The content hash is SHA-256 over one record per regular file, ordered by its relative path as binary strings. Paths use / separators and include no leading slash. Each record is the decimal byte length of the relative path, a colon, the path, a colon, the lowercase hexadecimal SHA-256 of the file bytes, and a newline. Empty directories and file metadata such as mtime are ignored. Entries named .git, .hg, and .svn are excluded at every depth. Composer’s installed metadata and generated autoload files live outside the package directory and are therefore not included; no package files are excluded as Composer rewrites. Symbolic links and non-regular files cause hashing to fail. The algorithm streams file contents and sorts one directory at a time.

When a Marketplace install or update fails verification for the extension or for any package the operation added or changed in composer.lock, Capell quarantines that whole changed set, names the failing package and the set in the failure message, and rolls the Composer state back. A completed rollback lifts the quarantine; a failed rollback leaves every package in the set quarantined. A quarantined package is never enabled or booted, whatever the strict setting, and doctor lists it with the failing package. After resolving the cause, run php artisan capell:extensions:release-quarantine <package>; it releases the package only if it verifies at that moment.

CAPELL_EXTENSION_VERIFICATION_STRICT=true is the default: a failure stops activation. With false, local install and enable paths log the package name and failure codes and continue; doctor still reports warnings. Marketplace operations always fail on verification errors. CAPELL_EXTENSION_ALLOW_COMPOSER_PLUGINS=false rejects packages declaring a Composer plugin; set it to true only after reviewing the plugin and Composer’s own plugin policy. Doctor checks installed extensions regardless of the strict setting.

In the CLI, a refusal reports the package, the first failure and the next action. In Admin, the installation failure reports the same reason and next action; ask the server administrator or extension author to correct it before retrying. A failed install is recorded as failed; an enable refusal leaves the existing state in place.

Failure codeAuthor or administrator action
not_installedInstall the intended Composer package and retry.
version_outside_constraintInstall a release matching the requested constraint.
not_an_upgradeSelect a release newer than the previous version.
composer_pluginRemove the plugin declaration or have the administrator review and explicitly allow it.
manifest_missingInclude capell.json in the distributed package and reinstall it.
manifest_invalidCorrect the manifest against the version 3 contract and reinstall it.
manifest_identity_mismatchMake the manifest name and requested slug match the intended extension.
autoload_escapes_packagePoint every autoload entry to an existing path inside the package.
provider_file_missingInclude the declared provider, contribution or health-check class at its PSR-4 path.
checksum_missingSupply the expected distribution checksum through a trusted package source.
content_hash_mismatchObtain the intended release from a trusted source and resolve the content mismatch.
content_hash_unreadableCheck that the package contains readable regular files and no symbolic links.
checksum_mismatchObtain the intended distribution from a trusted source and resolve the checksum mismatch before retrying.

Uninstall keeps extension-owned data by default so the package can be reinstalled later with its previous state intact:

Terminal window
php artisan capell:extension-uninstall vendor/example --dry-run
php artisan capell:extension-uninstall vendor/example

If the admin intentionally wants to remove extension-owned data, pass --delete-data. If the Composer package should also be removed, pass --delete-package; this deletes extension-owned data before running Composer removal.

Packages that own tables or other persistent state can implement Capell\Core\Contracts\Extensions\DeletesExtensionData on their service provider or a manifest provider class. Capell calls deleteExtensionData(PackageData $package) only when the admin chooses data deletion or deletes the package.

  • Optional packages must not register runtime providers until enabled.
  • Package writes belong in Actions, not resource classes or controllers.
  • User-facing strings belong in package translations.
  • Public frontend output must not include authoring markers, model IDs, field paths, package internals, permissions, or signed admin URLs.
  • Cacheable frontend output needs invalidation metadata in the manifest or explicit cache invalidation registration.

Use the serving callbacks when registration depends on Capell’s own boot sequence:

use Capell\Admin\Facades\CapellAdmin;
use Capell\Core\Facades\CapellCore;
CapellCore::serving(function (): void {
// Register Core runtime extensions here.
});
CapellAdmin::serving(function (): void {
// Register Filament/admin extensions here.
});

CapellCore::serving(...) listens for Capell\Core\Events\ServingCapell, which is dispatched once Core has registered its built-in assets and discoverable components. CapellAdmin::serving(...) listens for Capell\Admin\Events\ServingAdmin, which is dispatched from Filament’s serving callback and therefore only runs when the admin panel is serving.

Keep ordinary container bindings and configuration in the package service provider. Use these callbacks for extension registration that must happen after the corresponding Core or Admin surface is ready. There is no frontend serving event; frontend packages register through their enabled frontend provider and the frontend extension points.