Without the bootstrap file being available I loaded the framework without the application to check the performance like this in a folder called app.
$time_start = microtime(1);
define('_JEXEC', 1);
$base = str_replace("/app", "", __DIR__);
define('JPATH_BASE', $base);
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$db = JFactory::getDBO();
$query = $db->getQuery(true)
->select('*')
->from($db->qn('#__users'));
$db->setQuery($query);
$users = $db->loadObjectList();
echo "<pre>" . print_r($users,1) . "</pre>";
echo microtime(1) - $time_start;
die();
And then put
$time_start = microtime(1);
into the top of Joomla's index.php file and then ran the following script in the entry file of a dummy component with a menu item routing to a view of the component:
defined('_JEXEC') or die;
global $time_start;
$db = JFactory::getDBO();
$query = $db->getQuery(true)
->select('*')
->from($db->qn('#__users'));
$db->setQuery($query);
$users = $db->loadObjectList();
echo "<pre>" . print_r($users,1) . "</pre>";
echo microtime(1) - $time_start;
die();
Performance Results
without Joomla application
- 0.034259080886841
- 0.03374195098877
- 0.034512996673584
- 0.034684181213379
with Joomla application > router > menu + component
- 0.24458599090576
- 0.29617881774902
- 0.29315781593323
- 0.3031439781189
I think that is probably enough of a performance gain for me to stop looking for a faster approach and having the whole of the platform will probably be useful anyhow. But if anyone has any alternative slimmed down ways to serve up custom api endpoints using bits of the cms I would be interested to hear.