Bu geliştirici başvurusu şimdilik yalnızca İngilizcedir; kod örnekleri ve adlar iki dilde de aynıdır.
Modules (extensions) add features to IronCMS without touching the core. The system is WordPress-like in feel (drop a folder, declare a manifest, hook into the core) but uses PSR-4 namespaces for isolation and a versioned manifest for dependencies — so you get familiarity without the global-scope and collision problems.
Directory layout
Modules live under modules/ at the project root, namespaced by vendor:
modules/
└── Acme/
└── Seo/
├── module.json # manifest (required)
├── Module.php # bootstrap class (required)
├── Config/
│ └── Routes.php # auto-discovered when "hasRoutes": true
├── Controllers/ # @permission docblocks feed RBAC
├── Database/
│ └── Migrations/ # run on activate() when "hasMigrations": true
├── Views/ # namespaced views: Modules\Acme\Seo\Views
└── public/ # published to public/modules/acme/seo when "providesAssets": true- Folder path must match the manifest
namespace:Modules\Acme\Seo→
modules/Acme/Seo/.
- The loader registers the module's PSR-4 namespace at runtime, so all classes
under it autoload normally.
The manifest — module.json
{
"name": "acme/seo",
"title": "SEO Pack",
"description": "Meta tags, sitemaps and Open Graph for IronCMS.",
"version": "1.0.0",
"namespace": "Modules\\Acme\\Seo",
"bootstrap": "Modules\\Acme\\Seo\\Module",
"author": "Acme",
"authorUrl": "https://acme.example",
"license": "Commercial",
"requires": {
"php": ">=8.2",
"ironcms": ">=1.0.0",
"modules": {
"acme/core": ">=1.1"
}
},
"hasMigrations": true,
"hasRoutes": true,
"providesAssets": true,
"icon": "<svg ...></svg>",
"tags": ["seo", "marketing"]
}Field reference
| Field | Required | Type | Notes |
|---|---|---|---|
name | ✅ | string | vendor/slug, lowercase [a-z0-9-]. Unique identity. |
title | ✅ | string | Human-readable name shown in the admin. |
version | ✅ | string (semver) | MAJOR.MINOR.PATCH, e.g. 1.0.0. |
namespace | ✅ | string | PSR-4 root; must start with Modules\. |
bootstrap | string (FQCN) | Class implementing ModuleInterface. Default: {namespace}\Module. | |
description | string | Short summary. | |
author | string | ||
authorUrl | string (URL) | ||
license | string | e.g. MIT, Commercial. | |
requires | object | Dependency constraints (see below). | |
hasMigrations | bool | Module ships Database/Migrations. Default false. | |
hasRoutes | bool | Module ships Config/Routes.php. Default false. | |
providesAssets | bool | Module ships a public/ dir to publish. Default false. | |
icon | string | Inline SVG / asset path for the admin list. | |
tags | string[] | Free-form labels. |
requires and version constraints
requires.php, requires.ironcms and each entry of requires.modules use a single constraint string. Supported syntax:
| Constraint | Meaning |
|---|---|
*, "", any | any version |
1.2.3 | exact match |
>=1.2, >1.2, <=1.2, <1.2, =1.2.3 | comparison |
^1.2.3 | >=1.2.3 and <2.0.0 (compatible within the same major) |
Ranges and || are intentionally not supported — keep requirements simple.
The bootstrap class & lifecycle
Extend App\Libraries\Modules\AbstractModule and override only what you need.
<?php
namespace Modules\Acme\Seo;
use App\Libraries\Modules\AbstractModule;
class Module extends AbstractModule
{
/** Runs on every request while the module is enabled. */
public function boot(): void
{
// Add a sidebar item (WordPress-style self-wiring).
$this->addFilter('admin_menu', function (array $items) {
$items[] = [
'key' => 'acme-seo',
'title' => 'Acme/Seo.menu.title',
'route' => 'acme_seo',
'priority' => 75,
'icon' => $this->manifest()->icon,
];
return $items;
});
// Inject something into the admin <head>.
$this->addFilter('ironcms_admin_head', fn (string $head) => $head . '<!-- seo -->');
}
/** One-time, when the module is enabled. */
public function activate(): void
{
// Migrations declared via "hasMigrations" are run by the loader.
// Do any extra seeding here.
}
/** One-time, when the module is disabled. Keep user data. */
public function deactivate(): void
{
}
/** When the module is deleted. Drop tables/data here. */
public function uninstall(): void
{
}
}| Method | When it runs | Use for |
|---|---|---|
boot() | every request, module enabled | register hooks, filters, menu items, routes |
activate() | once, on enable | migrations, seed data, publish assets |
deactivate() | once, on disable | unregister side-effects; keep user data |
uninstall() | on delete | drop tables, remove all module data |
Helpers available from AbstractModule: $this->manifest(), $this->path('Views/x.php'), $this->addAction(...), $this->addFilter(...).
Database tables
A module that needs its own tables sets "hasMigrations": true and ships Database/Migrations/. The admin lifecycle then behaves like WordPress plugins:
| Admin action | What happens | Data |
|---|---|---|
| Install (first enable) | the module's migrations run (latest(), namespace-scoped), then activate() | tables created |
| Enable (re-activate) | the module boots again | tables kept |
| Disable | the module stops booting (menu/routes/hooks removed) | tables & data kept |
| Uninstall | uninstall() runs, then the module's migration-tracking rows are cleared | tables & data removed |
Rules:
- Drop your own tables in
uninstall()(or your migrationdown()). The
loader does not auto-rollback: CI4's regress() works by global batch across all namespaces, so rolling back a single module is unsafe.
- After uninstall the loader clears your module's rows from the migrations table
(scoped to your namespace) so a fresh install re-runs your migrations cleanly.
- Keep migrations idempotent (
CREATE TABLE IF NOT EXISTS) so
install → uninstall → reinstall cycles never error.
The admin Modules screen shows Install for a never-installed module and Enable once it is installed but disabled.
Hook catalog (core extension points)
Register these in boot(). The full action/filter API lives in app/Core.php (inAddAction / inAddFilter / inDoAction / inApplyFilters).
Filters (transform a value, must return it)
| Tag | Value | Purpose |
|---|---|---|
admin_menu | array $items | Add/modify sidebar items (see Config\AdminMenu for the item shape). |
ironcms_admin_head | string $html | Append markup to the admin <head>. |
ironcms_admin_footer | string $html | Append markup before </body>. |
ironcms_output | string $html | Final transform of the full rendered page. |
Actions (side effects, no return)
| Tag | Args | Purpose |
|---|---|---|
before_render | string $view, array $data | Run before a view renders via inRender(). |
after_render | string $view | Run after a view renders. |
Modules may also define their own tags with inDoAction() / inApplyFilters() for other modules to extend.
Module settings
A module registers settings fields through the settings_fields filter. They appear automatically in the admin Settings screen (it is registry-driven) and are persisted to the key-value options store. Namespace your keys to avoid clashes:
public function boot(): void
{
$this->addFilter('settings_fields', static function (array $fields) {
$fields[] = [
'key' => 'module:acme/seo:api_key', // namespaced; ':' and '/' are POST-safe
'group' => 'modules', // a tab; an unknown group creates a new tab
'type' => 'text', // text|textarea|email|number|password|toggle|select
'label' => 'API Key',
'default' => '',
'rules' => 'permit_empty',
];
return $fields;
});
}Read or write the value anywhere with the global helpers:
$key = setting('module:acme/seo:api_key'); // registry default used when unset
setting_set('module:acme/seo:api_key', 'abc123');Avoid . or spaces in keys — PHP rewrites those characters in POST field names.
Permissions
Admin controllers expose permissions through @permission docblocks; the core discovers them by reflection and wires them into RBAC:
/**
* @permission {controller}_{method} Manage SEO settings
*/
public function index() { /* ... */ }The loader extends this scan to enabled modules' controller directories, so a module's permissions appear in the Roles screen automatically.
Isolation & the module contract
Live in your own namespace.
- Every module class is under
Modules\Vendor\Slug— no global functions or
unprefixed classes.
- All product-facing strings are English and go through
lang()
(Modules/Acme/Seo language namespace). Turkish, if shipped, is a secondary locale only.
- Never strip the brand guard: the rendered admin
<title>must contain
"IronCMS" (enforced by inRender()).
Own your data — the data wall (enforced).
- Declare your tables in
dataSources(). The data capsule (admin export /
import) only ever reads or writes the tables you declared — never core or system tables. A capsule that references any other table is rejected; the raw SQL it carries is restricted to CREATE TABLE / INSERT INTO on your own (prefixed) tables; schema.sql / data.sql are SHA-256-verified against the manifest. There is no package signing — this structural wall is the guarantee.
- So a module can never use a capsule to write
users,settings, etc.
Read the core, extend via hooks — don't raw-write the core (contract).
- Read core data through its models / services (users, settings, media, pages…).
- Extend the core only through hooks and registries —
admin_menu,
settings_fields, action_center_recommendations, TranslatableTypes, module_data_sources, …
- Do not run raw
UPDATE/INSERTagainst core tables. PHP can't be
sandboxed, so this is a contract (like WordPress), not a hard wall — but the data capsule and good-citizen hooks keep a well-behaved module out of core data.
Boot idempotently.
boot()runs once per request; the loader guards against a double-boot, but keep
your registrations safe to re-run (e.g. guard schema checks with a static flag).
Don't clash.
- Namespace your routes and permissions. In dev / staging the loader logs a warning
when your module's permission name, or a route it registers, collides with the core or another module (it overrides silently otherwise).
Reference
- Contract & manifest classes:
app/Libraries/Modules/
(ModuleInterface, AbstractModule, ModuleManifest, ManifestValidator, VersionConstraint, ManifestException).
- A working reference module ships in step 7.6 under
modules/IronCms/Hello/.