I'm writing several joomla modules and I'd like to put common functions in the libraries folder. However I want to use them from a joomla Ajax call in my module. I'm preparing to upgrade from 3.x to 4.x
I have the Ajax working fine. The part I can't get to work is using the USE php.
I have:
libraries/practicemanagement/patientForm.php
and in my module i have in the entry php file
defined('_JEXEC') or die;
$doc = JFactory::getDocument();
require_once 'libraries/practicemanagement/patientForm.php';
require_once __DIR__ . '/helper.php';
$siteButtons = modPatientChargeCheckingHelper::getSiteButtons();
require JModuleHelper::getLayoutPath('mod_patient_charge_checking', $params->get('layout', 'default'));
the patietForm.php contains two functions:
<?php
trait patientForm
{
/**
* The Main Active Language
*
* @var string
*
* @since 3.0.9
*/
public static function getPxAddress($addressId){...}
public static function getSiteButtons($siteToUse =""){...}
}
The helper class has:
defined('_JEXEC') or die;
class modPatientChargeCheckingHelper
{
use patientForm;
public static function getAjax(){}
}
When the file loads it runs the getSiteButtons() function however I think this is running just because it is included via the require_once statement. When I try to use the Helper Ajax function it just gives a 500 error. I've searched the server log and there doesn't seem to be an issue. I've never used USE before so I'm guessing that I'm doing something wrong. I just need a pointer to help me figure out what.
thanks
php 7.4.33 Joomla! 3.10.11 Stable