vincentbean/laravel-plausible
Composer 安装命令:
composer require vincentbean/laravel-plausible
包简介
Laravel Plausible
README 文档
README
This package provides a blade view with the script tag for plausible and a wrapper to easily send custom events to Plausible.
Installation
You can install the package via composer:
composer require vincentbean/laravel-plausible
You can publish the config file with:
php artisan vendor:publish --provider="VincentBean\Plausible\LaravelPlausibleServiceProvider" --tag="config"
Add the following to your env:
PLAUSIBLE_TRACKING_DOMAIN=DOMAIN_YOU_WANT_TO_TRACK
PLAUSIBLE_DOMAIN=OPTIONAL_IF_SELF_HOSTING
Usage
This package supports both client side and server side tracking.
Client Side Tracking
Include the component in your layout to add the plausible script, with optional tracking extensions.
<x-plausible::tracking />
or
<x-plausible::tracking extensions="hash, outbound-links, etc.." />
Plausible will be available on the window object for sending custom events via Javascript:
plausible('event')
Server Side Tracking
Track pageviews server side using middleware.
Laravel 11:
// bootstrap/app.php return Application::configure(basePath: dirname(__DIR__)) // ... ->withMiddleware(function (Middleware $middleware) { // Append this middleware to track globally $middleware->web(append: [\VincentBean\Plausible\Middleware\TrackPlausiblePageviews::class]); }) // ...
Laravel 10 and earlier versions:
// app/Http/Kernel.php 'web' => [ // Add this middleware to the web group to track globally \VincentBean\Plausible\Middleware\TrackPlausiblePageviews::class, ],
Custom Events
You can trigger custom events on the server.
\VincentBean\Plausible\Events\PlausibleEvent::fire('custom event', ['country' => 'netherlands']);
If firing your event from a queued job or event listener, it might be necessary to pass on the user's ip and user-agent string which are used by Plausible to generate user session ID's.
\VincentBean\Plausible\Events\PlausibleEvent::fire('custom event', ['country' => 'netherlands'], headers: [ 'X-Forwarded-For' => $event->userIp, 'user-agent' => $event->userAgent ]);
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
vincentbean/laravel-plausible 适用场景与选型建议
vincentbean/laravel-plausible 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64.34k 次下载、GitHub Stars 达 25, 最近一次更新时间为 2021 年 09 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「VincentBean」 「laravel-plausible」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vincentbean/laravel-plausible 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vincentbean/laravel-plausible 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vincentbean/laravel-plausible 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple package for communicating with the Plausible API within Laravel.
Send server-side events from Laravel to Plausible.
Alfabank REST API integration
A lightweight Laravel package that seamlessly integrates Plausible Analytics into your Blade views. Plausible.io is a privacy-friendly, open-source alternative to Google Analytics.
A laravel package for interacting with plausible analytics api.
Laravel package for Accurate Online API integration.
统计信息
- 总下载量: 64.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 25
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-07