java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

piwik 插件开发入门教程

能阅读英文的小伙伴可以直接去官方读读,不过piwik官方文档的确很多,想理清楚需要一点功夫

https://developer.piwik.org/guides/getting-started-part-1

创建一个插件

./console generate:plugin --name="MyPlugin"

There are no commands defined in the "generate" namespace.

开启开发模式

./console development:enable

Development mode enabled

./console generate:plugin --name="MyPlugin"

自定义一个报告

./console generate:report

输入要在哪个插件下 输入MyPlugin

Enter the name of your plugin: MyPlugin
Enter the name of your report, for instance "Browser Families": Visitors
Enter the report category, for instance "Visitor" (you can reuse any existing category or define a new one): yuexiaosheng
Enter a documentation that describes the data of your report (you can leave it empty and define it later): haha
Enter the report dimension, for instance "Browser" (you can leave it either empty or use an existing one):

WARNING [2017-11-29 10:45:03] /Users/ge/ge/web/php/piwik/plugins/CoreConsole/Commands/GenerateReport.php(72): Warning - sprintf(): Too few arguments - Piwik 3.0.4 - Please report this message in the Piwik forums: http://forum.piwik.org (please do a search first as it might have been reported already)

You should now implement the method called "getVisitors()" in API.php
Enjoy!

一个叫Reports的文件夹创建了。

下面两个文件
GetVisitors.php Base.php

Base.php

 protected function init()
    {
        $this->categoryId = 'Yuexiaosheng';
    }

决定了你标签的名称

孩子标签名称

  $this->subcategoryId = 'Real-time Reports';
        $this->subcategoryId = $this->name;

目录下API.php是需要填写数据的地方

建立一个单页

$ ./console generate:controller

出来这个文件

Controller (plugins/MyPlugin/Controller.php)

能玩了。此文待续


This entry was posted in PHP and tagged . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/piwik-create-plugin/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply