Including third party library into plugin


#1

Hi,

i’m currently writing a plugin to display a qrcode as a widget.
I’m using the PHP QR Code library, but unfortunately i can’t get the stuff working.

I’ve genrated a plugin called QRCode and wrote a helperclass to generate the qr-code, called QRCodeGenerate.php:


<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

namespace Piwik\Plugins\QRCode;

require_once 'lib/phpqrcode/qrlib.php';


class QRCodeGenerator
{
    protected $url = null;

    public function __construct($url)
    {
        $this->url = $url;
    }

    public function get()
    {
        QRcode::png('PHP QR Code :)');

        // $output = '<img src="example_001_simple_png_output.php" />';

        return $output;
    }
}

(by using this example)

There has something to be wrong with the include (don’t blame me for that), but I’m not getting what…
The code always errors:


PHP Fatal error:  Call to undefined method Piwik\\Plugins\\QRCode\\QRCode::png() in /var/www/html/piwik/plugins/QRCode/QRCodeGenerator.php on line 28

Does anybody know how to do it right?

Thanks