承接 mattitjaab/matomo-proxy-laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mattitjaab/matomo-proxy-laravel

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mattitjaab/matomo-proxy-laravel

包简介

This is my package matomo-proxy-laravel

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a plug-and-play server-side Matomo tracking middleware for Laravel. Instead of embedding JavaScript trackers in your frontend, requests are tracked directly from your Laravel app to your Matomo instance, ensuring better privacy, ad-blocker resilience, and simplified integration.

Installation

Install the package via Composer:

composer require mattitjaab/matomo-proxy-laravel

Publish the config file:

php artisan vendor:publish --tag="matomo-proxy-laravel-config"

This will create a config/matomo-proxy-laravel.php file. Example:

return [
    'enabled' => env('MATOMO_ENABLED', true),

    // Full Matomo tracking endpoint (must include /matomo.php)
    'base_url' => env('MATOMO_BASE_URL', ''),

    // Matomo site ID
    'site_id' => env('MATOMO_SITE_ID', null),

    // Optional token_auth (can be null for anonymous tracking)
    'token' => env('MATOMO_TOKEN', null),

    // Paths that should never be tracked
    'ignore' => [
        'telescope/*', 'horizon/*', 'health', '_debugbar/*',
    ],

    // HTTP client behavior
    'timeout' => env('MATOMO_TIMEOUT', 2),
    'retry' => [
        'times' => env('MATOMO_RETRY_TIMES', 0),
        'sleep' => env('MATOMO_RETRY_SLEEP_MS', 100), // milliseconds
    ],
];

Usage

Register the middleware globally in your bootstrap/app.php:

->withMiddleware(function (Middleware $middleware): void {
    $middleware->append(\MattitjaAB\MatomoProxyLaravel\Middleware\MatomoProxyLaravelMiddleware::class);
})
  1. Configure your .env file:
MATOMO_ENABLED=true
MATOMO_BASE_URL=https://analytics.example.com/matomo.php
MATOMO_SITE_ID=1
MATOMO_TOKEN=null
MATOMO_TIMEOUT=2
MATOMO_RETRY_TIMES=0
MATOMO_RETRY_SLEEP_MS=100

✅ That’s it. All requests will now be tracked server-side in Matomo without requiring any frontend JS snippet.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-20