π Plugins¶
BakeKit's plugin system is built on Composer. Every plugin is treated as a standard CakePHP plugin and is dynamically autoloaded behind the scenes using Composer.
The Admin Panel lets you upload, extract, and activate plugins without manually editing files or running Composer from the terminal.
Plugins are stored in the root-level plugins/
directory.
π¦ ZIP Archive Structure¶
FileManager.zip
βββ FileManager/
βββ config/
βββ resources/
βββ src/
βββ templates/
βββ webroot/
βββ composer.json
π§± Requirements¶
Each plugin must contain a valid composer.json
, for example:
{
"name": "bakewizard/filemanager",
"description": "FileManager plugin for BakeKit CMS",
"type": "cakephp-plugin",
"autoload": {
"psr-4": {
"FileManager\\": "src/"
}
}
}
Optionally, you can define a parent plugin:
"extra": {
"parent-plugin": "Shop"
}
π How Plugin Loading Works¶
1. Upload¶
Go to Site Management β Plugins
, upload your .zip
. BakeKit extracts it to plugins/
.
2. Read Metadata¶
The system reads the pluginβs composer.json
to extract the description
and the optional extra.parent-plugin
key (used in the Admin Panel to indicate a parent plugin relationship β for example, a delivery plugin that depends on the Shop plugin).
3. Composer Integration¶
BakeKit uses its internal Composer setup to register the plugin:
composer.phar
is downloaded during BakeKit's installation and placed in thebin/
folder.- Composer is run in sandboxed mode using custom environment variables to isolate its cache and config.
- Itβs invoked via the phar:// wrapper.
- No need to touch your projectβs
composer.json
or use the CLI β Composer is invoked programmatically:php bin/composer.phar dump-autoload -o
- The plugin is ready to use instantly β no manual steps needed.
βοΈ Settings and Dashboard¶
BakeKit plugins are just standard CakePHP 5 plugins without any extra overhead. But when we want to set plugin settings via the Admin Panel, we need to add some structure.
1. π§© Settings Form¶
Create a form class at plugins/YourPluginName/src/Form/ConfigForm.php
Example:
<?php
declare(strict_types=1);
namespace FileManager\Form;
use Cake\Core\Configure;
use Cake\Form\Form;
use Cake\Form\Schema;
use Cake\Validation\Validator;
/**
* Config Form.
*/
class ConfigForm extends Form
{
#[\Override]
protected function _buildSchema(Schema $schema): Schema
{
return $schema->addField('basePath', 'string');
}
#[\Override]
public function validationDefault(Validator $validator): Validator
{
return $validator->scalar('basePath')
->allowEmptyString('basePath')
->add('basePath', 'validFolderChars', [
'rule' => ['custom', '/^(?!\/)(?!.*\.\.)([A-Za-z0-9_\-\/\.]+)$/'],
'message' => 'Only letters, numbers, dashes, underscores, slashes, and dots are allowed. No backslashes, "..", or leading slash.'
]);
}
#[\Override]
protected function _execute(array $data): bool
{
Configure::write($data);
return Configure::dump('FileManager', 'db', array_keys($data));
}
}
This form handles validation, saving configuration into the database, and auto-dumps the settings using CakePHPβs built-in Configure system.
2. πΌοΈ Settings Template¶
Add the template view at plugins/YourPluginName/templates/Admin/Dashboard/settings.php
Example:
<?php $this->assign('page', __('FileManager Settings')); ?>
<div class="card card-success card-outline">
<div class="card-header">
<div class="card-title"><?= __('Main') ?></div>
</div>
<?= $this->Form->create($settings, ['align' => 'horizontal']) ?>
<div class="card-body">
<?= $this->Form->control('basePath'); ?>
</div>
<div class="card-footer">
<?= $this->Form->button('<i class="fa-solid fa-save"></i> ' . __('Save'), [
'class' => 'btn-outline-success float-end',
'escapeTitle' => false
]) ?>
<?= $this->Html->link('<i class="fa-solid fa-times-circle"></i> ' . __('Cancel'), [
'controller' => 'Dashboard',
'action' => 'index'
], ['class' => 'btn btn-outline-danger', 'escape' => false]) ?>
</div>
<?= $this->Form->end() ?>
</div>
This page displays your pluginβs settings form in the Admin Panel.
You can link to this page via:
π http://yourdomain.com/admin/plugin-name/dashboard/settings
3. π§ Optional Dashboard¶
You can also add a custom dashboard view at plugins/YourPluginName/templates/Admin/Dashboard/index.php
Example:
<?php $this->assign('page', __('File Manager')); ?>
<div class="card">
<div class="card-header">
<div class="card-title"><i class="fa-solid fa-tachometer-alt"></i> <?= __('Dashboard') ?></div>
</div>
<div class="card-body">
<div class="list-group">
<?= $this->Html->link('<i class="fa-solid fa-cog"></i> Settings', ['plugin' => 'FileManager', 'controller' => 'Dashboard', 'action' => 'settings'], ['escape' => false, 'class' => 'list-group-item']) ?>
</div>
</div>
</div>
You can also link to this dashboard directly with:
π http://yourdomain.com/admin/plugin-name/dashboard
Thatβs it! Once these pieces are in place, your plugin will have a fully working Admin Panel settings and dashboard pages β the BakeKit way.
π Learn More¶
More about CakePHP 5 plugins and forms can be found in the official CakePHP Cookbook:
π https://book.cakephp.org/5/en/plugins.html
π https://book.cakephp.org/5/en/core-libraries/form.html
π‘ Tip¶
You can create your own plugins using cake bake plugin PluginName
, zip them up, and upload through the Admin panel.