Skip to content

console.xml ​

XML schema: console.xsd · Linking and validation.

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"?>
<quiqqer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://www.quiqqer.com/docs/schemas/2.x/console.xsd">
    <console>
        <tool exec="\Vendor\Package\Console\MyTool"/>
    </console>
</quiqqer>

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
<quiqqer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://www.quiqqer.com/docs/schemas/2.x/console.xsd">
    <console>
        <tool file="OPT_DIR/vendor/package/src/Console/MyTool.php"
              exec="\Vendor\Package\Console\MyTool"/>
    </console>
</quiqqer>

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
<quiqqer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://www.quiqqer.com/docs/schemas/2.x/console.xsd">
    <console>
        <tool exec="\QUI\Cron\Console\ExecCrons"/>
        <tool exec="\QUI\Cron\Console\AutoCreateCrons"/>
    </console>
</quiqqer>

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"?>
<quiqqer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://www.quiqqer.com/docs/schemas/2.x/console.xsd">
    <console>
        <tool exec="\QUI\Cron\Console\ExecCrons"/>
        <tool exec="\QUI\Cron\Console\AutoCreateCrons"/>
    </console>
</quiqqer>

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.