PHP code example of roundly-consulting / plausible-for-laravel
1. Go to this page and download the library: Download roundly-consulting/plausible-for-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
roundly-consulting / plausible-for-laravel example snippets
use RoundlyConsulting\Plausible\Enums\Metric;
use RoundlyConsulting\Plausible\Enums\Property;
use RoundlyConsulting\Plausible\Facades\Plausible;
$result = Plausible::stats()
->for('my-site.com')
->metrics(Metric::Visitors, Metric::Pageviews)
->last30Days()
->compare()
->aggregate(); // -> AggregateResult
$result->metric(Metric::Visitors); // 2001
$result->change(Metric::Visitors); // 30 — the change vs the previous 30 days
$sources = Plausible::stats()->for('my-site.com')->last7Days()
->breakdown(Property::VisitSource)
->rows(); // list<BreakdownRow>
use RoundlyConsulting\Plausible\DataTransferObjects\Revenue;
Plausible::events()->fromRequest(request())->event(
'Signup',
url: url('/register'),
props: ['plan' => 'pro'],
revenue: Revenue::of('49.00', 'EUR'),
);