Quantcast
Channel: Matomo forums - Latest topics
Viewing all articles
Browse latest Browse all 13974

How to Include third party library into plugin

$
0
0

@bssystems wrote:

Hi,

I have installed a third party library (Google api PHP Client) with composer and now I don't know how to include it in my plugin. (Piwik version is 3.0.2, PHP 7.1.x)

Under the plugin directory I run:

composer require google/apiclient:^2.0

The question: how can I use/include Google_Client class into Controller.php class? What's the class path?

My Controller.php

<?php
namespace Piwik\Plugins\MyPlugin;
use Piwik\View;
require __DIR__ . "/vendor/autoload.php"; //autoloader
class Controller extends \Piwik\Plugin\Controller
{
    public function index()
    {
        $client = new Google_Client(); //test Goggle_Client class
        return $this->renderTemplate('index', array(
            'answerToLife' => 42
        ));
    }
}

The error returned is:
The following error just broke Piwik (v3.0.2): Class 'Piwik\Plugins\MyPlugin\Google_Client' not found

Thanks in advance!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 13974

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>