Skip to content

Modules ​

Introduction ​

A module is a feature of the site delivered as Composer packages — redirects, SEO, contact forms, custom fields. Modules are to kitloom what plugins are to WordPress, with one important difference: code is installed by Composer during deployment, never uploaded through the admin panel.

The shape of a module ​

Every module is split into a domain package and one admin package per panel:

text
kitloom/seo               domain: head meta, robots.txt, sitemaps, schema.org
kitloom/seo-filament      admin: the SEO section and form blocks in Filament
kitloom/seo-nova          admin: the same in Nova

The domain package holds everything that works without an admin: models, migrations, what the module adds to the site's pages, routes, middleware, console commands. It never imports Filament or Nova.

The admin package holds resources, pages, form fields and the menu section. It depends on the domain package and on its panel.

This split is what lets one module serve both Filament and Nova sites, and lets a headless site install only the domain package.

What a module does on its own ​

Once installed, a module wires itself in. A site does not:

  • register service providers — Laravel package discovery does it;
  • add admin resources to a panel — the admin package attaches its section;
  • add middleware, rewrite rules or page parts — the domain package adds them;
  • implement interfaces for the module — the module asks registries what exists on the site.

A site changes a module's behaviour with config (admin switches), by binding its own implementation of a contract, or by extending its models through config('kitloom-wp-schema.models') — see Data.

Core packages and modules ​

Not every package is a module. The packages below form the platform; they are always loaded and do not appear on the Modules screen:

PackageRole
kitloom/wp-schemaWordPress schema: models, the model registry, contracts, post type and taxonomy registries, capabilities
kitloom/siteThe site, the way WordPress handles a request: rewrite rules, the main query, the template hierarchy, themes, page parts
kitloom/site-inertiaVue themes for the site
kitloom/settingsSite options, read in one query and cached
kitloom/shortcodes[tag attr="value"] parsing and rendering
kitloom/mediaAttachments, featured images, uploads
kitloom/navigationMenus and menu locations
kitloom/modulesThe module catalog, switching modules on and off, kitloom:make-module
kitloom/access, kitloom/permissionsSection permissions and roles

A package becomes a module by declaring itself in composer.json:

json
{
    "name": "kitloom/redirects",
    "extra": {
        "kitloom": {
            "module": {
                "name": "Redirections",
                "description": "301 redirects and the 404 monitor."
            }
        }
    }
}

Declared modules are listed on the Modules screen and can be deactivated. Their admin packages are found automatically: any installed package whose name ends in -filament or -nova and that requires the module directly.

Next ​