The TYPO3 console is a great tool in order to get things done quickly. It provides many commands that will ease your live with TYPO3 a lot. Even if you are not used to command line tools, you should, no, you must have a look at this post. 😉
TYPO3 Console: A CLI tool for TYPO3
Basically the TYPO3 Console enables you to run tasks which are doing “something” with your TYPO3 installation. Usually these are tasks that require several mouse clicks in the backend. Now they are available via your keyboard.
But first, let me add a small paragraph about “CLI phobia”.
Don’t be scared of the command line!
Probably you would say now: “Hmm, I’m a windows guy and do not have any experience using the command line. So that is nothing for me!”.
Sorry, this is completely wrong. The command line does not bite. The learning curve is not steep. So you will have success from the first moment.
And please do not conclude from a MS-DOS window to “modern shells”. The tools nowadays are much better usable than these ancient tools.
Installation and basic usage of the TYPO3 console
The installation of the TYPO3 console is quite easy. You can install it via the “Extension Manager” in the TYPO3 backend. Search the TER for “typo3_console” and install it as any other extension. After the installation, the script will be symlinked to your document root.
The second possibility is to install it via composer. A quick
composer require helhum/typo3-console is sufficient. Afterwards you can access the tool (usually) in the path
/vendor/bin/ below the file “composer.json”
The script is named
typo3cms. In order to see whether it is working, you should login to your website instance and call
typo3cms help from the document root (in case of the installation via the Extension Manager) or
./vendor/bin/typo3cms help from your website root (in case you installed it via composer).
Now you should see the list of all available commands of the TYPO3 console.
If there is an php error, you must check the php version, which is provided on your command line. The necessary command is
php --version. This must be equal to the version your TYPO3 instance is running. If the version number is too low, you need to add the path to the correct php binary right in front. In case of a big german hoster, whose default php version on the command line is 4.4.9, the complete command looks like:
/usr/local/bin/php7-70LATEST-CLI vendor/bin/typo3cms help
The following sections will give you an introduction to the most commands of this tool.
database command provides three subcommands:
How often do you look up the database access credentials in order to import or export to or from a database dump? With the command
typo3cms database:export > /path/to/your/dump this is not necessary any more … The TYPO3_console fetches the credentials automatically and runs the
mysqldump command transparently.
updateschema is equivalent to the “Database compare” in the InstallTool. Per default the command only adds fields and tables and changes column definition. You can specify, which operations should be performed.
Clearing the cache
Cache operations are probably the most executed task in the TYPO3 backend (#scnr). This command group allows you to clear caches via command line. Several option to define the caches to be cleared are available. You can restrict cache clearing certain cache groups, like pages or system. You can also limit the flushing to certain cachetags, you used in the system.
typo3cms cache:flushtags news_pressreleases or
This group deals with extension handling and performs tasks like setting up and removing extensions. You can setup a single extension with the command
typo3cms extension:setup <my-extensionkey>. This command executes all database migrations, imports all files and data and writes the default configuration. The subcommand
extension:setupactive does this for all activated
Furthermore you can (de-)activate extensions, dump autoload data and list all available extensions.
Working with configuration
configuration allows to read, set and remove values of, in and from the array
➜ t3trunk ./vendor/bin/typo3cms configuration:show MAIL
'transport' => 'mail',
'transport_smtp_server' => 'localhost:25',
'transport_smtp_encrypt' => '',
'transport_smtp_username' => '',
'transport_smtp_password' => '',
'transport_sendmail_command' => '/usr/sbin/sendmail -t -i ',
'transport_mbox_file' => '',
'defaultMailFromAddress' => '',
'defaultMailFromName' => '',
Nested parts can be referenced in a usual path notation, as you can see in the example below.
➜ t3trunk ./vendor/bin/typo3cms configuration:show MAIL/transport
install:setup allows you to install a complete TYPO3 instance via the command line. You may not run the graphical “1-2-3-4-x”-Wizard any more. Especially if you want a quick setup of an instance for testing purposes. A setup of TYPO3 including the introduction package is done in less than ten minutes.
The other two subcommands of
generatepackagestates. Their purpose is quite self-explaining.
Since the release 4.5.0 the TYPO_console allows you to run the available upgrade wizards. There is no need to do the click maranthon in the InstallTool any more.
list lists all upgrade wizard, that are scheduled for execution. Using the subcommand
all you can run all upgrade wizards, which are not done yet. If you want run just a specific wizard, the subcommand
wizard is your friend.
There are several more commands available for tasks like updating language files, generating a xsd file for fluid viewhelpers, running a certain scheduler task or locking backend access for editors and admins.
For a complete list and explanation you should definitly have a look at the current command reference on github.
If you think RTFM is too boring for you, the autocompletion might a thing for you.
Currently there are 36 (sub-)commands available via the TYPO3 console. Not counted all the properly registered command controllers in TYPO3 extensions like “EXT:Powermail” or “EXT:metaseo”. This is all hard to remember.
But the TYPO3_console brings a command which is able to generate an autocompletion file for zsh and bash. Here is the snippet, I used to create the file:
./vendor/bin/typo3cms autocomplete --shell=zsh > /.typo3cms_completion
echo "source /.typo3cms\_completion" >> /.zshrc
If you are using bash, you must adapt the zsh stuff to your needs and make sure that bash is able to cope with autocompletion. More details and links are available in the documentation of the TYPO3_console.
Creating additional commands
Good news! Not each and every command has to be implemented into the core of the TYPO3_console! The TYPO3_console provides access to every extbase command controller, which is properly registered within TYPO3.
So if you want to add functionality to the TYPO3_console, just create an extension containing command controllers. I recommend to choose a meaningful prefix for your command class. Something like “TaskCommandController” is not helpful, because all extensions, using it, will summed up there. This is different to the old “cli_dispatch.sh”, where the tasks were prefixed by the extension key.
First of all I want to thank Helmut Hummel for his dedication to the TYPO3 Console and the TYPO3 project as a whole. I really appreciate his commitment. If you think the same, get in contact with him and sponsor the next steps … or just do him some kind of favor … or just say thank you 🙂
I hope, that this post has been interesting for you. If so or if you know somebody, who could profit from it, please share this post via your favorite social network. For your convenience I added some share buttons at the end of this page.
I found the blog post image on pixabay . It was published by StartupStockPhotos under the CC0 public domain license. It was modified by myself using pablo on buffer.