Skip to content

Instantly share code, notes, and snippets.

@strsar
Created January 30, 2017 17:34
Show Gist options
  • Save strsar/b0631fb954fd3d960a6f72741531510a to your computer and use it in GitHub Desktop.
Save strsar/b0631fb954fd3d960a6f72741531510a to your computer and use it in GitHub Desktop.
[Joomla!] - Create standalone application
<?php
/**
* Custom standalone application
*
* @package Joomla.Cli
* @application Stand-alone
*/
define('_JEXEC', 1);
ini_set('magic_quotes_runtime', 0);
ini_set('max_execution_time', 0);
if(file_exists(dirname(dirname(__FILE__)).'/defines.php')){
require_once dirname(dirname(__FILE__)).'/defines.php';
}
if(!defined('_JDEFINES')){
define('JPATH_BASE', dirname(dirname(__FILE__)));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_LIBRARIES.'/import.php';
require_once JPATH_LIBRARIES.'/cms.php';
JError::$legacy = true;
require_once JPATH_CONFIGURATION.'/configuration.php';
/**
* Custom application class
*/
class CustomApplication extends JApplicationWeb {
protected function doExecute(){
$code = 'Code';
$site = JURI::current();
$return = $site.' - '.$code.' Example';
// Displays view
$this->setBody($return);
}
}
// Instantiate the application.
$application = CustomApplication::getInstance('CustomApplication');
// Run the application
$application->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment