Skip to content

Instantly share code, notes, and snippets.

@roland-d
Created May 21, 2014 12:14
Show Gist options
  • Save roland-d/3e0a1958bdab5ef95b0d to your computer and use it in GitHub Desktop.
Save roland-d/3e0a1958bdab5ef95b0d to your computer and use it in GitHub Desktop.
Bootstrapping an app for both Joomla 2.5 and Joomla 3.3
<?php
// Set flag that this is a parent file.
// We are a valid Joomla entry point.
define('_JEXEC', 1);
// Setup the base path related constants.
define('JPATH_BASE', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
define('JPATH_COMPONENT_ADMINISTRATOR', dirname(dirname(__FILE__)));
define('JPATH_PLATFORM', JPATH_BASE . '/libraries');
// Bootstrap the application.
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_PLATFORM . '/import.php';
// Register PHP namespaces if we are on Joomla 3
if (file_exists(JPATH_PLATFORM . '/classmap.php'))
{
JLoader::registerNamespace('Joomla', JPATH_PLATFORM . '/framework');
require_once JPATH_PLATFORM . '/classmap.php';
}
// Import the JApplicationWeb class from the platform.
jimport('joomla.application.web');
/**
* The import class.
*/
class Import extends JApplicationWeb
{
/**
* Execute the import.
*
* @return void.
*/
protected function doExecute()
{
// Put code here
}
}
JApplicationWeb::getInstance('Import')->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment