Skip to main content
A plugin is a folder in plugins/ with a manifest and a PHP class. It can add services, routes, event listeners, its own templates and database tables, content at hook positions on the home page, and front-end assets — without editing the core.

Layout

The manifest

id, name, version and class are required; description, author, requires and autoload are optional. requires lists what the plugin depends on, with version constraints — for example { "divine/core": "^1.0" }. A plugin whose requirements aren’t met isn’t activated.

Install and manage

New plugins are discovered automatically and start inactive. Manage them on the Plugins screen in the admin: The app keeps plugin state in plugins/state.json, so the plugins/ folder must be writable by the PHP container.

The plugin class

Extend Divine\Core\Plugin\AbstractPlugin and override only what you need. Active plugins load in this order on every request: autoload → register() → routes() → boot().

Templates

A plugin’s templates are available to Twig under @<name> — the last part of the plugin id with - replaced by _. For divine/example-hello, that’s @example_hello — in a controller that extends BaseHttpController:

Migrations

Plugin migrations are ordinary Phinx migrations in the folder migrations() returns. They run when the plugin is installed and are rolled back when it’s uninstalled. Write to the database through the BaseRepository helpers, like the core does (see Base classes).

Events

Subscribe by class name:

Hooks

Divine\Core\Module\HookRegistry::register($position, $template, $priority) renders a Twig template at a named position. Two positions exist, both on the home page: home.before_content and home.after_content. The template can be a core view, a module’s @namespace view or one of your plugin’s own templates.

Assets

make npm-build compiles each plugin’s Assets/main.ts (and the styles it imports) into public/scripts/plugins/ and public/styles/plugins/, named after the plugin folder. Nothing includes them automatically — register them in boot():

Forms and CSRF

POST forms must include {{ csrf_field() }}, or send the token in an X-CSRF-Token header. Routes under /api/ are exempt.

Base classes

Controllers can extend Divine\Core\Blueprints\BaseHttpController (rendering, redirects, flash messages, JSON responses, the signed-in user). Database code should extend Divine\Core\Blueprints\BaseRepository and write through insertRow(), updateRow() and insertAndGetId() — see Architecture.

Example plugin

The bundled plugins/example-hello is a complete example: routes, a controller, templates, a migration, front-end assets and the install/uninstall lifecycle. Install and activate it on the Plugins screen and open /hello.
Plugins aren’t loaded by bin/console.