jalendport / craft-base
Shared foundation for jalendport Craft CMS plugins
Fund package maintenance!
1.1.1
2026-07-16 16:57 UTC
Requires
- php: ^8.2
- craftcms/cms: ^5.0.0
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
- craftcms/rector: dev-main
- pestphp/pest: ^3.0
This package is auto-updated.
Last update: 2026-07-16 17:55:12 UTC
README
Base
The shared foundation under every jalendport Craft CMS plugin.
Features
- Base Plugin class — extend
jalendport\base\Plugininstead ofcraft\base\Pluginand get everything below for free. - Per-plugin logging — each plugin writes its own
storage/logs/<handle>-*.log, withMyPlugin::info()/::warning()/::error()static helpers. - Controller traits —
runAndReturn()for web controllers (success/failure responses done right) andrunAndExit()+ output helpers for console controllers. - Settings helpers — a
configWarning()Twig macro that flags settings overridden inconfig/<handle>.php, plusgetConfigOverrides()for disabling the fields a config file has taken control of. - Testing helpers — settings factories and an in-memory cache for unit-only Pest suites.
Usage
use jalendport\base\Plugin; class Altcha extends Plugin { public static Altcha $plugin; public function init(): void { parent::init(); // registers the log target, @altcha alias, shared template root self::$plugin = $this; $this->registerEventHandlers(); } }
Flag and disable the settings a config file has overridden:
protected function settingsHtml(): ?string { return Craft::$app->getView()->renderTemplate('altcha/settings', [ 'settings' => $this->getSettings(), 'overrides' => $this->getConfigOverrides(), ]); }
{% import 'jalendport-base/_macros' as base %}
{{ forms.lightswitchField({
label: 'Enabled'|t('altcha'),
name: 'enabled',
on: settings.enabled,
disabled: 'enabled' in overrides,
warning: base.configWarning('enabled', 'altcha'),
}) }}
Support
Found a bug or have a question? Open an issue.
Made by Jalen Davenport
Icon: base by Lars Meiertoberens from Noun Project (CC BY 3.0)