Note 004 · Architecture1 min read
Plugins without imports: registries in a Laravel CMS core
How MN-Core loads payment and SMS code it has never heard of, and switches off a plugin that breaks.
MN-Core's core never imports a plugin by name. A plugin is a Composer package with a manifest and a service provider, and everything it brings (settings, permissions, admin screens, health checks, payment or SMS drivers) goes into registries the core declares.
Registries, not string hooks
WordPress-style hooks are strings: easy to add, easy to misspell, and invisible to "go to definition". Here each extension point is a typed class, such as SettingsRegistry, HealthChecks, AdminNavigation or SmsManager, and a plugin's provider calls it when the plugin boots:
protected function bootPlugin(): void
{
NetgsmSettings::register(app(SettingsRegistry::class));
NetgsmSettings::registerProvider(app(SmsManager::class));
}The code of every first-party plugin ships in the image, but a plugin registers nothing until it is installed on that instance. A site that never installs the Turkish SMS plugin has no tables, settings or routes for it.
A broken plugin shouldn't take the site with it
Uploaded plugins are inspected before anything in them runs, and their signature is checked. Install, update and uninstall steps run in a separate process. If a plugin still throws while booting, it is switched off and the site carries on.
What it costs
Registry contracts are an API, and breaking one breaks every plugin that uses it. So each plugin declares which core versions it supports, and the core checks that before activating or updating it.
- Laravel