Botble CMS plugins follow a modular architecture that allows for easy extension of the core functionality. Each plugin is a self-contained module with its own controllers, models, views, assets, and configuration files.
All plugins must include a plugin.json
file for metadata and are manually registered with Composer autoloader.
activate()
: Run logic when plugin is activated (e.g., default settings)deactivate()
: Run logic when plugin is deactivatedremove()
: Clean up database tables, settings, and other dataEach plugin requires a plugin.json
file with the following fields:
name
: Display name of the pluginnamespace
: PHP namespace of the plugin (must end with double backslash)provider
: Fully qualified ServiceProvider classauthor
: Plugin authorurl
: Website for the plugin or authorversion
: Plugin versiondescription
: Brief descriptionminimum_core_version
: Minimum Botble CMS version requiredExample:
{
"name": "Foo",
"namespace": "Botble\\Foo\\",
"provider": "Botble\\Foo\\Providers\\FooServiceProvider",
"author": "Your Name",
"url": "https://yourwebsite.com",
"version": "1.0",
"description": "A simple foo plugin for Botble CMS",
"minimum_core_version": "7.3.0"
}
platform/plugins/foo/
├── config/
│ └── permissions.php
├── database/
│ ├── migrations/
│ └── seeders/
├── helpers/
├── resources/
│ ├── assets/
│ ├── lang/
│ └── views/
├── routes/
│ └── web.php
├── src/
│ ├── Forms/
│ ├── Http/
│ │ ├── Controllers/
│ │ └── Requests/
│ ├── Models/
│ ├── Providers/
│ │ └── FooServiceProvider.php
│ ├── Repositories/
│ └── Plugin.php
└── plugin.json
register()
to bind implementations to the service containerboot()
to load and publish configurations, views, translations, migrations, and register menu itemsLoadAndPublishDataTrait
for helper methods like loadHelpers()
and loadRoutes()
Defines hierarchical permissions for the plugin:
return [
[
'name' => 'Foo',
'flag' => 'foo.index',
],
[
'name' => 'Create',
'flag' => 'foo.create',
'parent_flag' => 'foo.index',
],
[
'name' => 'Edit',
'flag' => 'foo.edit',
'parent_flag' => 'foo.index',
],
[
'name' => 'Delete',
'flag' => 'foo.destroy',
'parent_flag' => 'foo.index',
],
];
FooServiceProvider
)foo.items.create
)$item_count
)FOO_MODULE_SCREEN_NAME
)plugins/foo::items.create
)getItems()
)