<developers/>

Hooks and events

Run your own code when an invoice is created, a client changes or the automation ticks, from an add-on module.

Last changed 12 Nov 2026

How events work#

An add-on module lists the events it listens to in its events() method, as event name => method name. CoreInto calls that method with one array of data when the event happens, only while the module is active. A module that throws does not stop CoreInto: the error is logged and the work carries on.

namespace Acme\Mod\Slack;

use CoreInto\Addons\Addon;

final class Module extends Addon
{
    public function events(): array
    {
        return [
            'invoice.created' => 'onInvoice',
            'client.created' => 'onClient',
            'tick' => 'onTick',
        ];
    }

    public function onInvoice(array $data): void
    {
        // $data: invoice_id, gateway, draft
    }

    public function onClient(array $data): void
    {
        // $data: client_id, opt_in
    }

    public function onTick(array $data): void
    {
        // every few minutes, from the automation: send what is queued
    }
}

The events#

EventWhenData
invoice.createdAn invoice is made: for an order, by the renewal run, from billable items, a quote, a debit note or by handinvoice_id, gateway, draft
invoice.gatewayAn invoice's payment method is chosen or changedinvoice_id, gateway, previous
invoice.changedAn invoice's amounts change, for example when its currency is changedinvoice_id, reason
client.createdA client account is made, by sign-up, order, staff or the APIclient_id, opt_in
client.updatedA client's profile changesclient_id, changed (the fields), old_email
client.marketingA client opts in to or out of marketing emailclient_id, opt_in
tickEvery few minutes, from the automationnone

Use tick for slow work, such as calling another service, instead of doing it while a page is being shown: queue it in the event, send it in tick.

The page head#

head(string $area, array $page): string returns HTML put at the end of the page head of the client area and store ('client') or the website ('site'). $page has path, client_id (0 when nobody is signed in) and events, such as ['purchase' => [...]] on the page after an order, with the order number, value, currency and items. The Google Analytics module uses this to report purchases. Scripts must follow the page security policy: load them from your module's assets or a host the policy allows.

Other hooks of an add-on module#

MethodWhat it does
activate() / deactivate()Create your tables with CREATE TABLE IF NOT EXISTS; keep data on deactivate
adminRoutes()Pages under /admin, each with a permission
menu()Items in the Add-ons menu
configRoute()Your settings page
registrars()Registrar modules the add-on brings
whois() and whoisTlds()WHOIS answers for extensions you handle
conf() and saveConf()Read and save your settings

The add-on modules page has the folder layout and the manifest.

Frequently asked questions

Does a failing hook break CoreInto?

No. The error is logged and CoreInto carries on.

Where should slow work go?

In the tick event, which runs every few minutes from the automation, not in an event that fires while a page is shown.