Skip to content

Instantly share code, notes, and snippets.

Last active March 15, 2023 09:17
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Simple Joomla 4 CLI script
// listusers.php - simple cli script to dump users on CLI
// Written by René Kreijveld
// Version history:
// 1.0, 2023-03-09: Initial version
use Joomla\CMS\Factory;
const _JEXEC = 1;
define('JDEBUG', false);
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
require_once dirname(__DIR__) . '/defines.php';
if (!defined('_JDEFINES'))
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
// Get the framework
require_once JPATH_BASE . '/includes/framework.php';
// Function to output a message
function out($message)
echo $message . "\n";
// Setup database
$db = Factory::getContainer()->get('DatabaseDriver');
// Get data from users table
$query = $db->getQuery(true)
$users = $db->loadObjectList();
foreach ($users as $user)
out("id: $user->id, username: $user->username, name: $user->name, email: $user->email");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment