Skip to content

console.xml

console.xml registers package console tools for the QUIQQER console.

Use it when a package provides maintenance commands, import/export tasks, cleanup jobs, or support tools that should run from the shell.

Basic Structure

Create console.xml in the package root.

xml
<?xml version="1.0" encoding="UTF-8"?>
<console>
    <tool exec="\Vendor\Package\Console\MyTool"/>
</console>

The exec attribute contains the fully qualified PHP class name of the console tool.

QUIQQER reads all tool entries below console. Each entry can load one tool class.

Loading A Tool File

Normally the tool class is loaded through Composer autoloading. Older or special packages can additionally include a PHP file before the class is registered.

xml
<console>
    <tool file="OPT_DIR/vendor/package/src/Console/MyTool.php"
          exec="\Vendor\Package\Console\MyTool"/>
</console>

Use file only when autoloading is not enough. New packages should prefer autoloadable classes and only set exec.

Tool Classes

Registered tool classes should extend QUI\System\Console\Tool.

php
<?php

namespace Vendor\Package\Console;

use QUI;

class MyTool extends QUI\System\Console\Tool
{
    public function __construct()
    {
        $this->setName('vendor-package:task')
            ->setDescription('Run a package task.');
    }

    public function execute(): void
    {
        $this->writeLn('Task completed.');
    }
}

Use setName() for the command name and setDescription() for the help text.

Multiple Tools

A package can register more than one tool.

xml
<console>
    <tool exec="\QUI\Cron\Console\ExecCrons"/>
    <tool exec="\QUI\Cron\Console\AutoCreateCrons"/>
</console>

Use separate tool classes for separate tasks. This keeps command names, arguments, and help output clear.

Arguments

Declare arguments in the tool class with addArgument().

php
$this->addArgument('limit', 'Maximum number of records to process', 'l', true);

Read arguments with getArgument().

php
$limit = $this->getArgument('limit');

Do not use reserved argument names such as help, tool, listtools, u, p, username, or password for package-specific arguments.

Real Package Shape

quiqqer/cron registers two console tools:

xml
<?xml version="1.0" encoding="UTF-8"?>
<console>
    <tool exec="\QUI\Cron\Console\ExecCrons"/>
    <tool exec="\QUI\Cron\Console\AutoCreateCrons"/>
</console>

QUI\Cron\Console\ExecCrons extends QUI\System\Console\Tool, sets the command name to package:cron, and implements cron execution and listing behavior.

Practical Checklist

Before adding console.xml:

  • Register only autoloadable tool classes.
  • Extend QUI\System\Console\Tool.
  • Use file only for special compatibility cases.
  • Use clear package-scoped command names.
  • Add arguments through the tool class.
  • Print actionable output for success and failure cases.
  • Keep destructive or security-sensitive behavior protected in the tool logic.

Released under GPL-3.0-or-later.