teraone/matomo-client

Laravel 的 Matomo API 客户端库

v1.1.1 2024-06-04 10:20 UTC

This package is auto-updated.

Last update: 2024-09-04 10:58:53 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

此包基于 VisualAppeal/Matomo-PHP-API

安装

您可以通过 composer 安装此包

composer require teraone/matomo-client

发布和编辑配置文件

php artisan vendor:publish
  • 选择 matomo-client
  • 使用您的 Matomo 凭据更新文件 app/config/matomo-client.php

用法

为了保持简单,仅支持 JSON 格式。所有方法返回一个 Illuminate\Http\Client\Response

// get the Matomo Client
$matomoClient = app()->get('matomo-client');

// get Visits of this month
$matomo->setDate(now(), MatomoClient::PERIOD_MONTH)
       ->setFilterLimit(10) // defaults to 100
       ->getVisits()
       ->json();



// get Event Names of the last week
$matomo->setDate(now()->subWeek(), MatomoClient::PERIOD_RANGE, now())
        ->getEventName()
        ->json();

测试

底层使用 Laravel HTTP 客户端。

您可以在测试中模拟所有请求

Http::fake(
  'https://matomo.test/index.php*' => \Http::response(['value' => 123], 200),
);

更新日志

有关最近更改的更多信息,请参阅 更新日志

贡献

有关详细信息,请参阅 贡献指南

安全性

如果您发现任何安全相关的问题,请通过电子邮件 gotre@teraone.de 联系我们,而不是使用问题跟踪器。

致谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件