Facades and Container Keys

The services a plugin registers into. Each is a singleton bound by a core provider and rebuilt on every request, so register into them on every request that needs them.

Facade (App\Facades\…)Container keyClassRegister from
MenuManagermenumanagerApp\Services\MenuManagerAdminBooting listener
MenuBuildermenubuildermanagerApp\Services\MenuBuilderManagerAdminBooting listener
SettingsManagersettingsmanagerApp\Services\Settings\SettingsAdminBooting listener
DashboarddashboardApp\Services\Dashboard\DashboardRegistryboot()
ShortcodeshortcodesApp\Services\PageBuilder\ShortcodeRegistryboot()
WidgetsSeoWidgetApp\Services\WidgetManagerboot()
AppPagesapp-pagesApp\Services\AppPages\PageRegistryboot()
RolesrolesmanagerApp\Services\RoleManagerCore only (team roles)
UniqueSlugFacadeuniqueslugApp\Helpers\Classes\UniqueSlug— (a helper)
AgentagentDetection\MobileDetect (device detection)—
Meta—Head tags; TruCMS macros setMeta(), setFont()Controllers
—BindingSourceRegistry::classApp\Services\PageBuilder\Bindings\BindingSourceRegistryboot()
—PageBuilderAssetRegistry::class (per request)App\Services\PageBuilder\Assets\PageBuilderAssetRegistryRender time
—ThemeOptionStore::class, ThemeOptionsSchema::class, ThemeCssCompiler::classApp\Services\Themes\…—

The admin sidebar. Items are App\Services\Menu\MenuItems. Guide: Admin menu and dashboard.

MethodPurpose
make(string $key, callable $callable, ?int $order = null): selfCreate or replace an entry; the callable receives a MenuItems
get(string $key): ?MenuItems, has(string $key): boolRead an entry (add sub-menus to it)
remove(string $key): self, clear(): selfDelete entries
all(bool $admin = true), adminMenus(), frontMenus(), count()Read the sorted collection

Sources an editor can drag into a menu in Appearance → Menus. Guide: Menus and navigation.

MethodPurpose
register(string $key, callable $callable, ?int $order = null): selfAdd a container; the callable receives a MenuContainer
get(string $key): ?MenuContainer, find(string $menu): bool, all()Read containers

SettingsManager

Settings sections, pages and fields. Guide: Settings screens.

MethodPurpose
add(array $data): selfRegister a section (id, title, link, pages). Re-using an id appends pages to that section
section(string $key): Section|falseRead a registered section
all(): CollectionAll sections

Dashboard

Named dashboards made of rows and items. Guide: The dashboard.

MethodPurpose
admin(), user(), for(?string $name)The admin home, the visitor account dashboard, or any named dashboard (a DashboardDefinition)
->row($name, $order, $class, $permission)Create or fetch a row
->widget(), ->include(), ->component(), ->html()Add an item to the row
rows(?string $name)Read rows
removeRow($dashboard, $row), removeItem($dashboard, $row, $item), removeDashboard($name), clear()Take things away

Render a dashboard in Blade with @dashboard('name'). Constants: DashboardRegistry::DEFAULT_DASHBOARD (admin.dashboard) and USER_DASHBOARD (user.dashboard).

Shortcode

Page-builder blocks. Guide: Shortcodes.

MethodPurpose
register(string $class), registerIfMissing(string $class)Register a class that implements ShortcodeContract. register() throws on a duplicate id
replace(string $class)Replace an existing definition with yours
category(string $id, string $label, int $priority = 100), group(string $shortcodeId, string $category)Register a block-panel category, or move a shortcode into one
has($id), get($id), handler($id), all(), grouped(), categories(), definitionForTag($tag)Read the registry
registerMarker(string $marker, array $assets, ?string $id = null)Load assets on pages whose content contains a marker string
registerContentAssets(string $content)Queue the assets of every shortcode found in a piece of content (the page renderer calls it)

Widgets

Front-end widgets for widget areas. Guide: Widgets and widget areas.

MethodPurpose
register(string $key, string $widget): stringMake a widget class selectable
get(string $key): ?string, find(string $widget): bool, all(): CollectionRead the registry

AppPages

Named page types an administrator maps to a CMS page. Guide: Page types and public URLs.

MethodPurpose
register(PageDefinition|Closure $definition), registerMany(iterable $definitions)Add page types (build them with PageDefinition::make($key); a closure is called immediately and must return one)
selectedPage(string $key): ?Page, selectedPageUrl(string $key): ?stringThe page the site chose for a type, and its URL
forPage(Page $page), firstForPage(Page $page)Which types a given page serves
has(), get(), forget(), definitions(), all()Read and edit the registry

BindingSourceRegistry

Data-bound section sources. Resolve with app(BindingSourceRegistry::class). Guide: Data-bound sections.

MethodPurpose
register(BindingSource $source), registerIfMissing(BindingSource $source)Add a source instance
has($key), get($key), all(?array $keys), editorPayload()Read the registry

PageBuilderAssetRegistry

Collects the scripts and styles that page-builder content needs during one request; the layout prints them. You rarely call it directly: declare assets on your shortcode definition instead.

MethodPurpose
registerVite(string|array $entries, string $bundle = 'application', int $priority = 100)Queue Vite entries
registerStyle(string $url, ...), registerScript(string $url, ...)Queue plain URLs
render(string $placement), hasAssets(), reset()Output and housekeeping

Meta

php — in a public controller

use App\Facades\Meta;

Meta::setMeta($testimonial);               // title, description, canonical, Open Graph, Twitter Card
Meta::setTitle(__('testimonials::testimonials.menu'));
Meta::setDescription($summary);

setMeta($model) reads meta_title/title, meta_description and an og-image media collection when the model has them.

Other services worth knowing

ClassUse
App\Services\ResponseCache\ResponseCacheInvalidatorflush(), flushWhenChanged(array $models). See Caching
App\Services\ResponseCache\CacheProfilekeepOutOfCache(), GUESTS_ONLY
App\Services\Slugs\SlugManager, SlugResolverThe global slug registry behind HasSlug
App\Services\AuthenticatorTwo-factor checks used by both 2FA middlewares
App\Services\GeoLocationServiceIP to location (used for billing zones)
Modules\TruPayments\Services\PaymentManager, GatewaySettingsPayments; see Payments and gateways
Nwidart\Modules\Facades\ModuleisEnabled(), find(), plus TruCMS macros requirements(), requiredBy(), withRequirements(), withPayment(), paymentModules()