Created
May 28, 2024 10:36
-
-
Save renekreijveld/03cb8ef52907a7c1827c318e4f0a6683 to your computer and use it in GitHub Desktop.
Joomla 5 CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Joomla\CMS\Factory; | |
const _JEXEC = 1; | |
define( 'JDEBUG', false ); | |
define( 'JPATH_BASE', dirname( dirname( __FILE__ ) ) ); | |
require_once JPATH_BASE . '/includes/defines.php'; | |
require_once JPATH_BASE . '/includes/framework.php'; | |
// Boot the DI container | |
$container = Factory::getContainer(); | |
$session_alias = 'session.web'; | |
$session_suffix = 'web.site'; | |
// Alias the session service key to the web session service. | |
$container->alias( $session_alias, 'session.' . $session_suffix ) | |
->alias( 'JSession', 'session.' . $session_suffix ) | |
->alias( \Joomla\CMS\Session\Session::class, 'session.' . $session_suffix ) | |
->alias( \Joomla\Session\Session::class, 'session.' . $session_suffix ) | |
->alias( \Joomla\Session\SessionInterface::class, 'session.' . $session_suffix ); | |
// Instantiate the application. | |
$app = $container->get( \Joomla\CMS\Application\SiteApplication::class); | |
// Set the application as global app | |
Factory::$application = $app; | |
// Setup database | |
$db = Factory::getContainer()->get( 'DatabaseDriver' ); | |
/* your code comes here */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment