now requires two factor authentication through Google Authenticator. Should you need assistance with the two factor authentication please report the problem via a support ticket. close

Home Documentation 1.2.2 Web Developers Components Helpers




A helper class is a class filled with static methods and is usually used to isolate a "useful" algorithm. They are used to assist in providing some functionality, though that functionality isn't the main goal of the application. They're also used to reduce the amount of redundancy in your code.


Helper classes are stored in the helper sub-directory of your component directory. Naming convention typically follows a pattern of {ComponentName)Helper(HelperName}. Therefore, our helper class is called HelloHelperOutput.

Here's our com_hello/helpers/output.php helper class:

// No direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

 * Hello World Component Helper
class HelloHelperOutput
	 * Method to make all text upper case
	  * @access    public
	public static function shout($txt='')
		return strToUpper($txt).'!';

We have one method in this class that takes all strings passed to it and returns them uppercase with an exclamation point attached to the end. To use this helper, we do the following:

class HelloControllerHello extends Hubzero\Component\SiteController
	public function display()

		$greeting = HelloHelperOutput::shout("Hello World");  
		$this->set( 'greeting', $greeting );  

Last modified: