Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Piwik Api Laravel Package

devhelp/piwik-api

Laravel package to integrate with the Piwik/Matomo API. Provides a simple PHP client wrapper and configuration to query analytics data (sites, visits, events, reports) from your application without dealing with low-level HTTP calls.

View on GitHub
Deep Wiki
Context7

Provides self-contained piwik methods that are able to make call to api with predefined or/and runtime arguments

Frequently asked questions about Piwik Api
What Laravel versions does devhelp/piwik-api support?
The package is designed for Laravel 5.x and likely works with newer versions, but no explicit Laravel 10+ support is documented. Test compatibility by checking the package’s Guzzle HTTP client version and Laravel’s dependency constraints in `composer.json`. If issues arise, consider wrapping the API calls with Laravel’s HTTP client for better version alignment.
How do I securely store the Piwik API token in Laravel?
Use Laravel’s `.env` file to store the `PIWIK_TOKEN` and bind it to the package’s configuration. For enhanced security, leverage Laravel Vault or environment variables with encrypted values. Avoid hardcoding tokens in configuration files or source code.
Can I use this package with Matomo (Piwik’s successor) v4+?
The package should work with Matomo, but compatibility isn’t guaranteed due to lack of recent updates. Verify the API endpoints (e.g., `Actions.getPageUrl`) match Matomo’s v4+ documentation. If issues arise, consider forking the package or using Matomo’s official PHP SDK as a fallback.
How do I mock Piwik API responses in PHPUnit tests?
Use Laravel’s HTTP testing helpers or libraries like VCR or Mockery to stub the Piwik API responses. For example, mock the `PiwikGuzzleClient` to return predefined JSON responses. Alternatively, create a test double that implements the same interface as the Piwik client.
Does this package support custom Piwik segments or complex queries?
The package supports runtime arguments and lazy-loaded parameters, including segments, but complex queries may require manual overrides. For advanced use cases, extend the `Param` interface or pass custom arrays to method calls. Check the [Piwik API documentation](http://developer.piwik.org/api-reference/reporting-api-segmentation) for segment syntax.
How do I handle API rate limits or timeouts in production?
The package lacks built-in retry logic, so integrate Laravel’s HTTP client for retries and timeouts. Configure Guzzle’s retry middleware or use Laravel’s `Http::timeout()` and `Http::retry()` methods. Cache frequent API responses with Laravel’s cache system to reduce load.
What’s the best way to integrate this into a Laravel service container?
Register the Piwik client as a singleton in `AppServiceProvider` using Laravel’s dependency injection. Bind the `PiwikApi` class to the container with your `.env` configuration, then inject it into services or facades. Example: `$this->app->singleton(PiwikApi::class, fn($app) => new PiwikApi(config('piwik.token')));`.
Are there alternatives to this package for Laravel?
Consider Matomo’s official PHP SDK for active maintenance and full feature support. For lightweight needs, use Laravel’s HTTP client directly with Guzzle or Symfony’s HTTP client. If you need a facade-like interface, wrap the official SDK in a Laravel-specific package.
How do I lazy-load dynamic parameters like `token_auth`?
Implement the `Param` interface or use callbacks for dynamic values. For example, pass a closure to resolve `token_auth` at runtime, such as fetching it from the current user’s session. The package resolves these values when `call()` is invoked, enabling flexible parameter handling.
Can I use this package for real-time analytics tracking?
The package is optimized for querying historical data (e.g., visits, events) rather than real-time tracking. For real-time needs, use Piwik’s JavaScript tracker or Matomo’s official API directly. Cache frequent queries to reduce latency in your Laravel application.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky