Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to load helper from plugin in custom controller

2 years 3 months ago #209415 by jackrabbithanna
I'm working on upgrading an old Limesurvey 2.x with lots of customs to 3.x or 4.x

The instance has some custom controllers, which load some custom helpers.

I want to move the helper out into a Limesurvey plugin (and controllers too but ..)

So it looks like helper was loaded like this:

Where SomeHelperObject.php is in ./survey/application/helpers/customdir

Is there an standard way to load helpers from a LS Plugin?
Can helpers from plugins be loaded from controllers?
The topic has been locked.
2 years 3 months ago #209422 by DenisChenu
There are no standard way

But check Yii alias :

Alias is added here : gitlab.com/SondagesPro/coreAndTools/lime...ter/limeMpdf.php#L32

With plugin : i don't know how you construct controller, not real controller.

For administration : see github.com/LimeSurvey/LimeSurvey/blob/5c...PluginHelper.php#L21

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
2 years 3 months ago #209426 by jackrabbithanna
This is good .. I had a plugin, but didn't have that one line in the init() of the plugin php script

So I have a basic plugin like so:
class lfSurveyVersions extends PluginBase

static protected $name = 'lfSurveyVersions';
static protected $description = 'Customs for Survey Versions functionality';

protected $storage = 'DbStorage';

public function init() {
Yii::setPathOfAlias(get_class($this), dirname(__FILE__));

Then inside the plugin directory, a helpers directory, and a name space like:
namespace lfSurveyVersions\helpers;
Something for tests I had a simple object
class TempHelper {
static public function someFunction() {
return 25;


Now enable plugin

Then in my controller .. am able to use like so:
$value = \lfSurveyVersions\helpers\TempHelper::someFunction();

And that works .. Thanks for the help!
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose