Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Promokit Library (pklib)

Overview

Promokit Library is a lightweight utility library used by other Promokit modules. It provides shared services and helpers such as cache adapters, file manager utilities, admin tab installation helpers and general-purpose utilities.

This module is not intended to provide frontend features by itself — instead it exposes reusable building blocks for other modules in the Promokit suite.

What it provides

  • Admin Tabs installer (src/Tabs/Tabs.php) — helper to register/unregister admin tabs used by Promokit modules. The module class exposes Tabs::TABS and will create them during install().
  • Cache adapters (src/Cache/Cache.php, src/Cache/CacheBase.php, src/Cache/File.php) — simple caching layer used across modules. Use these to implement lightweight persistent caching.
  • FileManager (src/FileManager/FileManager.php) — utilities for safe file operations and content management.
  • ResponseHandler (src/ResponseHandler/ResponseHandler.php) — uniform response wrapper used by internal controllers and AJAX endpoints.
  • Utilities (src/Utils/Utils.php) — general helpers:
    • isSerialized($string) — checks whether a string contains serialized PHP data.
    • executeHook($module, $initiator, $params = []) — helper to instantiate and execute hook handler classes in the module's Hooks namespace.
  • Installer helper (src/Installer/Installer.php) — common installation/uninstallation routines used by Promokit modules.

How other modules use pklib

  • Rely on Pklib for admin tab creation during module install/uninstall (the module registers the tabs defined in Tabs::TABS).
  • Use the cache adapters to store preprocessed data (images, API responses) with a consistent API.
  • Use FileManager for reading/writing module assets safely.
  • Call Utils::executeHook($module, $initiator, $params) from module classes to delegate hook handling to classes in src/Hooks (this mirrors how Promokit modules structure hook classes).

Code locations

  • src/Tabs/Tabs.php — admin tabs management and installation logic.
  • src/Cache/ — cache adapters and base classes.
  • src/FileManager/FileManager.php — file utilities.
  • src/ResponseHandler/ResponseHandler.php — response wrapper.
  • src/Utils/Utils.php — general-purpose helpers.
  • src/Installer/Installer.php — installer helper used during module install flows.