Technical Library / Open Source

Joomla Snippets

Searchable collection of production-ready code recipes for template overrides, modules, plugins, and Joomla! 3 to 6 APIs.

100 Snippets
12 Categories
J3 to J6 Compatibility
Showing 6 of 6 snippets
Bash / CLI J6 J5 J4 CLI
CLI and Automation

Clean Cache and Reindex Smart Search via Joomla CLI

Runs cache:clean and finder:index purge via official cli/joomla.php without browser or PHP-FPM timeouts.

# Limpa todo o cache de sistema e itens expirados
php cli/joomla.php cache:clean
php cli/joomla.php cache:clean-expired

# Limpa e reconstrói integralmente o índice do Smart Search (com_finder)
php cli/joomla.php finder:index purge
64 210
Bash / CLI J6 J5 J4 CLI
CLI and Automation

Discover and Install Git-Deployed Extensions with extension:discover

Registers components, modules and plugins pulled from Git directly through the Joomla 5 and 6 CLI.

# 1) Escaneia novas extensões presentes nas pastas do Joomla
php cli/joomla.php extension:discover

# 2) Lista as extensões descobertas e seus Extension IDs
php cli/joomla.php extension:discover:list

# 3) Instala uma extensão específica pelo ID (ex: 447)
// ...
45 153
Bash / CLI J6 J5 J4 CLI
CLI and Automation

Run Joomla Task Scheduler (com_scheduler) via Real Server Cron

Replaces visitor-triggered Lazy Scheduler with reliable server Crontab execution using scheduler:run --all.

# Listar todas as tarefas agendadas cadastradas no Joomla
php cli/joomla.php scheduler:list

# Executar todas as tarefas pendentes manualmente
php cli/joomla.php scheduler:run --all

# Entrada recomendada no Crontab (a cada 5 minutos, com trava flock)
// ...
51 167
Bash / CLI J6 J5 J4 CLI
CLI and Automation

Toggle Maintenance Mode (Offline) via CLI During Deployments

Puts Joomla offline, pulls updates, cleans cache and brings the site back live cleanly using site:down and site:up.

# Coloca o site em manutenção
php cli/joomla.php site:down

# Atualiza o código via Git-First e limpa o cache
git pull origin master
php cli/joomla.php cache:clean

// ...
37 130
Bash / CLI J6 J5 J4 CLI
CLI and Automation

Check Core Updates and Export Safe UTF-8 Backups via CLI

Checks Joomla core update status via core:check-updates, lists installed extensions and produces atomic utf8mb4 backups.

# Verifica se há novas versões do Joomla disponíveis
php cli/joomla.php core:check-updates

# Exporta dump SQL consistente em UTF-8 (utf8mb4) fora do public_html
mkdir -p ~/backups
mysqldump --single-transaction --quick --default-character-set=utf8mb4 \
  "$DB_NAME" | gzip > ~/backups/joomla_$(date +%Y%m%d_%H%M).sql.gz
45 149
PHP J6 J5 CLI
CLI and Automation

Create a Custom Joomla CLI Command Extending AbstractCommand

Adds custom subcommands to php cli/joomla.php (e.g. example:sync) with SymfonyStyle output, arguments and options.

<?php

declare(strict_types=1);

namespace Vendor\Plugin\Console\Example\CliCommand;

\defined('_JEXEC') or die;
// ...
48 160
Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.