core23/matomo-bundle

该包已废弃,不再维护。作者建议使用nucleos/matomo-bundle包。

此捆绑包为在symfony应用程序中使用Matomo提供块服务。

4.2.0 2024-08-14 16:26 UTC

README

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Continuous Integration Code Coverage Type Coverage

此捆绑包为在symfony sonata-project中使用的matomo (Piwik) 统计信息提供包装器。

安装

打开命令行,进入您的项目目录,然后执行以下命令以下载此捆绑包的最新稳定版本

composer require nucleos/matomo-bundle
# To define a default http client and message factory
composer require symfony/http-client nyholm/psr7

启用捆绑包

然后,通过将其添加到项目中的config/bundles.php文件中注册捆绑包的列表来启用捆绑包

// config/bundles.php

return [
    // ...
    Nucleos\MatomoBundle\NucleosMatomoBundle::class => ['all' => true],
];

资产

建议使用webpack / webpack-encoreMatomoTable.js文件包含在您的页面中。这些文件位于assets文件夹中。

您可以使用npmyarn来加载库

用法

在您的配置中定义一个HTTP客户端。

# config/packages/nucleos_matomo.yaml

nucleos_matomo:
    http:
        client: 'httplug.client'
        message_factory: 'nyholm.psr7.psr17_factory'

渲染跟踪代码

{{ sonata_block_render({ 'type': 'nucleos_matomo.block.tracker' }, {
    'host': 'http://matomo.example.com',
    'site': 1
}) }}

渲染统计图表

{{ sonata_block_render({ 'type': 'nucleos_matomo.block.statistic' }, {
    'host': 'http://matomo.example.com',
    'site': 1,
    'token': 'MATOMO_API_TOKEN'
}) }}

许可证

此捆绑包遵循MIT许可证