Development

The Joomla CLI is better than you think

The Joomla CLI is better than you think

There is a command line tool in every Joomla install, at cli/joomla.php. It handles updates, extensions, cache and config without a browser anywhere near it.

Run it with no arguments from the root of your site and it lists what it can do:

php cli/joomla.php

What follows is the part worth knowing about.

Updating core

php cli/joomla.php core:update:check
php cli/joomla.php core:update

This is the same update the admin performs, without the browser timing out halfway through on a slow host. On a big site it is noticeably more reliable.

Extensions

php cli/joomla.php extension:list
php cli/joomla.php extension:install --path=/path/to/package.zip
php cli/joomla.php extension:enable
php cli/joomla.php extension:disable
php cli/joomla.php extension:remove

extension:list is the fastest way to answer "what is actually installed on this site", which matters when you take over a site from someone else.

There is also a discover pair, for extensions whose files are on disk but not registered:

php cli/joomla.php extension:discover
php cli/joomla.php extension:discover:install

Configuration

php cli/joomla.php config:get
php cli/joomla.php config:set offline=true

Handy when a bad setting has locked you out of the admin. Rather than editing configuration.php by hand and risking a syntax error, set the one value and move on.

Cache and maintenance

php cli/joomla.php cache:clean
php cli/joomla.php maintenance:database

The database one checks and fixes the schema, the same as the admin's database tab. Worth running after any manual database work.

Search and scheduling

php cli/joomla.php finder:index
php cli/joomla.php scheduler:run
php cli/joomla.php scheduler:list

The one requirement

Your command line PHP has to be able to reach the database. On shared hosting the CLI PHP is often a different build from the one your web server uses, with a different socket or a different set of extensions. If the CLI says it cannot connect while the site works fine, that is almost always the reason. Check with php -i | grep mysql and compare it against a phpinfo() page.

Stuck on something else?

Doctor Joomla is a project of Cloudfaction, a Dutch agency building and maintaining Joomla sites since 1999. The articles are made with the help of AI, so tell us if something does not match your screen. Mail info@cloudfaction.nl if you want someone to look at yours.

Rather have someone look at it

Doctor Joomla is a Cloudfaction project.

A Dutch agency that has been building and running Joomla sites since 1999. If your site needs more than an article can fix, get in touch.