DEV Community


Posted on

LimeSurvey HelloWorld Plugin

The following code is needed to run a simple command on the command line within LimeSurvey.
Your folder structure under upload/plugins should be like this:

  • HelloWorld
    • config.xml
    • HelloWorld.php
<?xml version="1.0" encoding="UTF-8"?>
        <author>My Name</author>
        <authorEmail>My Email Address</authorEmail>
        <authorUrl>MY Homepage</authorUrl>
        <description><![CDATA[This Plugin does some magic on the command line]]></description>

Enter fullscreen mode Exit fullscreen mode
class HelloWorld extends PluginBase
    protected $storage = 'LimeSurvey\PluginManager\DbStorage';
    static protected $description = 'HelloWorld';
    static protected $name = 'HelloWorld';

     * subscribe to all needed events
     * @see
    public function init()
        /** @see */

     * php application/commands/console.php plugin --target=HelloWorld
    public function direct()
        $event = $this->getEvent();
        $target = $event->get('target');
        if ($target != get_class()) return;

        echo 'HELLO WORLD' . PHP_EOL;

Enter fullscreen mode Exit fullscreen mode

In LimeSurvey's PluginManager scan files, install and activate the plugin.
Then on the command line run:
php application/commands/console.php plugin --target=HelloWorld

And hopefully you can see: Hello World


Top comments (0)