09 December 2014

How to load Joomla framework into your non Joomla/ external php script

Load the Joomla! Framework in a Non-Joomla! PHP Script:
If you've ever had the need to load the Joomla! framework inside an external, non-Joomla! PHP script (say, when using Jumi), you can use this handy script to load the necessary files to allow you to use Joomla! classes in your PHP script.
define( '_JEXEC', 1 );
define( '_VALID_MOS', 1 );
// JPATH_BASE should point to Joomla!'s root directory
define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

No comments:

Post a Comment