Console commands (cli)

It is possible to run TYPO3 scripts from the command line. This functionality can be used to set up cron jobs, for example.

TYPO3 uses Symfony commands API for writing CLI (command line interface) commands. These commands can also be run from the TYPO3 scheduler if this option is not disabled in the Configuration/Services.yaml.

Run a command from the command line

You can list the available commands by calling:

vendor/bin/typo3

For example, you can clear all caches by calling:

vendor/bin/typo3 cache:flush

Show help for the command:

vendor/bin/typo3 cache:flush -h

Running the command from the scheduler

By default, it is possible to run a command from the TYPO3 scheduler as well. To do this, select the task Execute console commands followed by your command in the Schedulable Command field.

Note

You need to save and reopen the task to define command arguments.

In order to prevent commands from being set up as scheduler tasks, see deactivating-the-command-in-scheduler.

Create a custom command

You can create a custom command by extending \Symfony\Component\Console\Command\Command.

See the Tutorial: Create a console command for details on how to create commands.

A command has to be registered as a tag of name console.command:

EXT:some_extension/Configuration/Services.yaml
services:
  Vendor\SomeExtension\Command\DoThingsCommand:
    tags:
      - name: 'console.command'
        command: 'someextension:dothings'
        description: 'An example command that demonstrates some stuff'
        schedulable: true
        hidden: false
schedulable

By default, a command can be used in the scheduler too. This can be disabled by setting schedulable to false.

hidden

A command can be hidden from the command list by setting hidden to true.

Read more