Hello,
I have a website that's in Joomla 5 and runs just fine, but I have some custom php tools that will run outside of Joomla. These tools are built in Slim 4. Since the access controls are configured in Joomla I want to get the user object of someone who is logged in and pass the user ID of the logged in user to my Slim 4 code. I've dug around the forums and found this code that I've trying to build as a middleware in my Slim application:
However on this line I get the following error:
From what I'm seeing online, the solution is to update Joomla, but I'm already running 5.1.0. Any suggestions of how to tackle this would be appreciated
I have a website that's in Joomla 5 and runs just fine, but I have some custom php tools that will run outside of Joomla. These tools are built in Slim 4. Since the access controls are configured in Joomla I want to get the user object of someone who is logged in and pass the user ID of the logged in user to my Slim 4 code. I've dug around the forums and found this code that I've trying to build as a middleware in my Slim application:
Code:
define('_JEXEC', 1);define ('JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ]);require_once JPATH_BASE . '/includes/defines.php';require_once JPATH_BASE . '/includes/framework.php';// Boot the DI container$joomlaContainer = \Joomla\CMS\Factory::getContainer();$joomlaContainer->alias ('session.web', 'session.web.site')->alias ('session', 'session.web.site')->alias ('JSession', 'session.web.site')->alias (\Joomla\CMS\Session\Session::class, 'session.web.site')->alias (\Joomla\Session\Session::class, 'session.web.site')->alias (\Joomla\Session\SessionInterface::class, 'session.web.site');// Instantiate the application$joomlaApp = $joomlaContainer->get (\Joomla\CMS\Application\SiteApplication::class);// Set the application as global app\Joomla\CMS\Factory::$application = $joomlaApp;//Get user info$userInfo = \Joomla\CMS\Factory::getApplication()->getSession()->get('user');
Code:
$joomlaContainer = \Joomla\CMS\Factory::getContainer();
Code:
Compile Error: Declaration of Joomla\DI\Container::has($resourceName) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool
Statistics: Posted by Pallieguy — Tue Apr 16, 2024 7:15 pm