Rename package to mattitja/laravel-plausible-proxy
dependabot-auto-merge / dependabot (pull_request_target) Skipped
Fix PHP code style issues / php-code-styling (push) Successful in 6s
PHPStan / phpstan (push) Successful in 2m32s
run-tests / P8.3 - L11.* - prefer-lowest - ubuntu-latest (push) Failing after 34s
run-tests / P8.4 - L11.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L11.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L12.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L12.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L12.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L12.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L11.* - prefer-stable - ubuntu-latest (push) Canceled after 2s
dependabot-auto-merge / dependabot (pull_request_target) Skipped
Fix PHP code style issues / php-code-styling (push) Successful in 6s
PHPStan / phpstan (push) Successful in 2m32s
run-tests / P8.3 - L11.* - prefer-lowest - ubuntu-latest (push) Failing after 34s
run-tests / P8.4 - L11.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L11.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L12.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L12.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L12.* - prefer-lowest - ubuntu-latest (push) Canceled after 0s
run-tests / P8.4 - L12.* - prefer-stable - ubuntu-latest (push) Canceled after 0s
run-tests / P8.3 - L11.* - prefer-stable - ubuntu-latest (push) Canceled after 2s
- Rename Composer package to mattitja/laravel-plausible-proxy and namespace to Mattitja\LaravelPlausibleProxy - Point homepage and links to git.mattitja.se - Forward only User-Agent and visitor IP (X-Forwarded-For) to Plausible instead of all request headers - Forward all event fields and return Plausible's upstream response - Accept props as array or JSON string - Drop Laravel 10, upgrade Larastan to 3 and PHPStan plugins to 2 - Remove broken facade alias and dead autoload paths - Clean up README, issue template and remove invalid FUNDING.yml
This commit is contained in:
16 files changed
+141
-112
No files matched your search
@@ -1,21 +1,22 @@
|
||||
# laravel-plausible-proxy
|
||||
|
||||
[](https://packagist.org/packages/mattitjaab/laravel-plausible-proxy)
|
||||
[](https://github.com/mattitjaab/laravel-plausible-proxy/actions?query=workflow%3Arun-tests+branch%3Amain)
|
||||
[](https://github.com/mattitjaab/laravel-plausible-proxy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
|
||||
[](https://packagist.org/packages/mattitjaab/laravel-plausible-proxy)
|
||||
[](https://packagist.org/packages/mattitja/laravel-plausible-proxy)
|
||||
[](https://git.mattitja.se/Github/laravel-plausible-proxy/actions?workflow=run-tests.yml)
|
||||
[](https://git.mattitja.se/Github/laravel-plausible-proxy/actions?workflow=fix-php-code-style-issues.yml)
|
||||
[](https://packagist.org/packages/mattitja/laravel-plausible-proxy)
|
||||
|
||||
A Laravel package for proxying Plausible Analytics, improving performance.
|
||||
A Laravel package for proxying Plausible Analytics, improving performance and privacy.
|
||||
|
||||
## Requirements
|
||||
- Laravel 12
|
||||
- PHP 8.3, 8.4
|
||||
|
||||
## 🚀 Installation
|
||||
- Laravel 11 or 12
|
||||
- PHP 8.3 or 8.4
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install the package via Composer:
|
||||
```sh
|
||||
composer require mattitjaab/laravel-plausible-proxy
|
||||
composer require mattitja/laravel-plausible-proxy
|
||||
```
|
||||
|
||||
2. Publish the configuration file:
|
||||
@@ -23,14 +24,14 @@ A Laravel package for proxying Plausible Analytics, improving performance.
|
||||
php artisan vendor:publish --tag=plausible-proxy-config
|
||||
```
|
||||
|
||||
3. Add the following environment variables to your `.env` file:
|
||||
3. Add the following environment variable to your `.env` file:
|
||||
```env
|
||||
PLAUSIBLE_DOMAIN=https://plausible.io
|
||||
```
|
||||
|
||||
## ⚙️ Configuration
|
||||
## Configuration
|
||||
|
||||
The `config/plausible-proxy.php` file allows you to customize the plausible domain:
|
||||
The `config/plausible-proxy.php` file allows you to customize the Plausible domain:
|
||||
|
||||
```php
|
||||
return [
|
||||
@@ -38,30 +39,42 @@ return [
|
||||
];
|
||||
```
|
||||
|
||||
## 🔥 Usage
|
||||
## Usage
|
||||
|
||||
### 1. Proxying the JavaScript file
|
||||
|
||||
### **1. Proxying the JavaScript file**
|
||||
This package proxies Plausible's `script.js` while caching it to improve performance and reduce external requests.
|
||||
|
||||
After installation, you can include the script like this:
|
||||
|
||||
```html
|
||||
<script defer data-domain="example.com" src="/js/script.js"></script>
|
||||
```
|
||||
|
||||
The route `/js/script.js` is automatically handled and caches the script for **6 hours**.
|
||||
The route `/js/script.js` is handled automatically and caches the script for 6 hours.
|
||||
|
||||
### **2. Sending Events to Plausible**
|
||||
Instead of sending events directly to plausible.io, the script is loaded from /js/script.js and proxies the request to Plausible via /api/event, helping to prevent blocking by ad blockers.
|
||||
### 2. Sending events to Plausible
|
||||
|
||||
## ✅ Features
|
||||
The script loaded from `/js/script.js` sends events to `/api/event` on your own domain, which forwards them to Plausible. This helps prevent blocking by ad blockers.
|
||||
|
||||
- 🚀 **Fast & Optimized**: Caches the Plausible script to reduce external calls.
|
||||
- ✅ No issues with ad blockers: Proxies the request via a local API endpoint.
|
||||
- 🛠 **Fully Configurable**: Easily set your own Plausible instance via `.env`.
|
||||
Only the visitor's `User-Agent` and IP address (as `X-Forwarded-For`) are forwarded to Plausible, which is what Plausible needs to count unique visitors. Cookies and other request headers are never forwarded.
|
||||
|
||||
## 🛠 Testing
|
||||
If your application runs behind a load balancer or reverse proxy, make sure Laravel's [trusted proxies](https://laravel.com/docs/requests#configuring-trusted-proxies) are configured so the correct visitor IP is resolved.
|
||||
|
||||
## Upgrading from mattitjaab/laravel-plausible-proxy
|
||||
|
||||
Version 2.0 renames the package and its namespace:
|
||||
|
||||
1. Replace the package:
|
||||
```sh
|
||||
composer remove mattitjaab/laravel-plausible-proxy
|
||||
composer require mattitja/laravel-plausible-proxy
|
||||
```
|
||||
2. If you reference any package classes directly, change the namespace from `MattitjaAB\LaravelPlausibleProxy` to `Mattitja\LaravelPlausibleProxy`.
|
||||
3. Laravel 10 is no longer supported.
|
||||
|
||||
## Testing
|
||||
|
||||
You can run tests with:
|
||||
```sh
|
||||
composer test
|
||||
```
|
||||
@@ -70,18 +83,13 @@ composer test
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
|
||||
Please report security vulnerabilities by email to hej@mattitja.se.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Mathias Palmqvist](https://github.com/mathiaspalmqvist)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in new issue
Block a user