Подключение фреймворка Joomla

Joomla! 5

    if(empty($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = 'mysite.ru';
    if(strpos($_SERVER['SCRIPT_NAME'], 'index.php') === false) $_SERVER['SCRIPT_NAME'] = '/'.basename($_SERVER['SCRIPT_NAME']);

    define('_JEXEC', true);
    require_once __DIR__.'/../../includes/defines.php';
    require_once __DIR__.'/../../includes/framework.php';

    use Joomla\CMS\Factory;

    $db = Factory::getDbo();
    print_r($db);

 

Joomla! 4

  define('_JEXEC', 1);
  if(empty($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = 'xn--b1ageonfb6e.xn--p1ai';
  if(strpos($_SERVER['SCRIPT_NAME'], 'index.php') === false) $_SERVER['SCRIPT_NAME'] = '/'.basename($_SERVER['SCRIPT_NAME']);
  require_once dirname(__DIR__).'/includes/console.php';

 

Joomla! 3 и ниже

  define('_JEXEC', 1);
  if(strpos($_SERVER['SCRIPT_NAME'], 'index.php') === false) $_SERVER['SCRIPT_NAME'] = '/'.basename($_SERVER['SCRIPT_NAME']);
  define('DS', '/');
  define('JPATH_BASE', realpath(dirname(__FILE__)."/.."));
  require_once(JPATH_BASE."/includes/defines.php");
  require_once(JPATH_SITE."/includes/framework.php");

  // Вызвать обработчик плагина:
  JPluginHelper::importPlugin('system', 'infobot');
  $resp = $app->triggerEvent('onSendLog', array($text));