Skip to main content

CLI-Ready Components

Enable native Joomla CLI command support in your generated components.

What Is It?

Joomla Component Builder (JCB) includes support for building CLI-ready components by generating command-line accessible classes that hook directly into Joomlaโ€™s CLI framework.

This allows developers and administrators to interact with their components from the terminal โ€” ideal for automated tasks, scheduled scripts, bulk imports/exports, and headless operations.

CLI integration is compiled into your component using JCBโ€™s GUI and custom code injection system. No manual bootstrap or loader setup is required.

Key Features

  • Native Joomla 4/5 CLI Compatibility
    JCB compiles CLI command classes that extend Joomla's ConsoleApplication structure โ€” ready to run via php cli/joomla.php or bin/joomla.
  • Per-Component Namespace Support
    Each CLI command is generated in its component's namespace, allowing clean organization and autoloading.
  • Reuse JCB Logic in CLI
    Access models, services, or custom logic (e.g., imports, cron jobs) from CLI, just like you would via HTTP.
  • Custom Command Registration
    CLI commands are registered via a dedicated CLI manifest or service provider pattern, generated automatically.
  • Easy Command Setup
    Define your CLI entry point using JCBโ€™s Custom Code system or JCBโ€™s boilerplate examples for common tasks (e.g., rebuild cache, sync data).
  • ACL Support for Secure Execution
    While CLI bypasses user sessions, you can still integrate checks to restrict tasks by token, environment, or logic layer.

Example Use Cases

  • Automated daily import/export routines
  • Mass file processing or cleanup
  • Background data analysis
  • Content publishing or archiving jobs
  • Remote API syncs or pings
  • Headless component usage (Joomla as data engine)

How to Build CLI Commands in JCB

  1. In your component entity in JCB, create a new plugin that includes all the necessary PHP code for the CLI command.
  2. Link the plugin to the component using the "Component Plugin" section.
  3. Compile the component โ€” JCB will automatically generate the required CLI registration scaffolding.
  4. Install the compiled plugin and enable it in your Joomla system.
  5. Run your command via the terminal in the Joomla CLI folder:./joomla.php cli:commands

Developer Notes

  • CLI Plugins are stateless and environment-dependent โ€” ensure services like DB or filesystem are initialized.
  • JCB allows placeholders inside Plugins (e.g. [[[ComponentNamespace]]], '[[[component]]]:Item:import').
  • You can create multiple CLI orientated Plugins per component and link them automatically.

CLI & JCB Integration Workflow

  • Use Init/Reset/Pull to manage CLI Plugins
  • Compile Plugins as part of regular JCB builds
  • Inject superpowers, joomlapowers, or custom logic into Plugins
  • Maintain Plugins as entities in JCB like other Views and Fields

Conclusion

JCB makes your component command-line ready โ€” allowing real automation and modern devops workflows. Whether you're building internal tooling or need production-ready headless logic, CLI support extends your componentโ€™s power far beyond the web interface.