Connecting to an external database in Joomla 3 is easy following this documentation and works like a charm. But JDatabaseDriver->getInstance method is deprecated in Joomla 4. What is the alternative method to do it in Joomla 4?

1 Answer 1


Use Joomla\Database\DatabaseFactory::getDriver():

$db = (new Joomla\Database\DatabaseFactory)->getDriver('mysqli', $options);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.