Load Joomla 3.x Framework and Modules in external PHP file

余生长醉 提交于 2019-11-28 01:21:09
Lodder

The following works perfectly for me:

define('_JEXEC', 1);
define('JPATH_BASE', '../');
require_once JPATH_BASE . 'includes/defines.php';
require_once JPATH_BASE . 'includes/framework.php';

// Create the Application
$app = JFactory::getApplication('site');

Try changing this line which you currently have to a relative path as shown above. You may been to change ../ according to where you have your Joomla root in relation to your external file.

define('JPATH_BASE', '/var/customers/webs/tf2swiss/joomlasite');

To test if it's working, simply use something like this:

var_dump($app);

If you see data being shown, then your have successfully imported the framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!